[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:52 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=d36977b
The following commit has been merged in the master branch:
commit d36977b14f18b888737ba64e67c1e52572106539
Author: Marcin Ziemiński <zieminn at gmail.com>
Date: Thu Aug 21 22:47:00 2014 +0200
Use KTp::OTR library
---
app/CMakeLists.txt | 1 +
app/chat-window.cpp | 10 +-
app/main.cpp | 4 +-
cmake/modules/FindKTp.cmake | 2 +
config/CMakeLists.txt | 1 +
config/otr-config.cpp | 19 +-
config/otr-config.h | 6 +-
lib/CMakeLists.txt | 7 +-
lib/authenticationwizard.cpp | 9 +-
lib/authenticationwizard.h | 11 +-
lib/channel-adapter.cpp | 452 ---------------------
lib/channel-adapter.h | 113 ------
lib/chat-widget.cpp | 35 +-
lib/chat-widget.h | 7 +-
lib/otr-channel-proxy.cpp | 52 ---
lib/otr-channel-proxy.h | 690 ---------------------------------
lib/otr-constants.h | 126 ------
lib/otr-status.cpp | 52 +++
lib/{otr-utils.h => otr-status.h} | 36 +-
lib/otr-types.cpp | 67 ----
lib/otr-types.h | 83 ----
lib/otr-utils.cpp | 124 ------
lib/proxy-service-interface.cpp | 45 ---
lib/proxy-service-interface.h | 352 -----------------
lib/proxy-service.cpp | 14 +-
lib/proxy-service.h | 5 +-
logviewer/entity-view.h => lib/types.h | 35 +-
27 files changed, 141 insertions(+), 2217 deletions(-)
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 33184cd..e9b15ed 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -20,6 +20,7 @@ set (ktp-text-ui_LIBS
${KTP_LIBRARIES}
${KTP_MODELS_LIBRARIES}
${KTP_WIDGETS_LIBRARIES}
+ ${KTP_OTR_LIBRARIES}
${QT_QTWEBKIT_LIBRARY}
${KDE4_KNOTIFYCONFIG_LIBS}
${KDE4_KCMUTILS_LIBS}
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index fa8e561..d1279fb 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -24,7 +24,6 @@
#include "chat-search-bar.h"
#include "chat-tab.h"
#include "chat-widget.h"
-#include "otr-constants.h"
#include <KTp/service-availability-checker.h>
#include <KTp/actions.h>
@@ -74,6 +73,7 @@
#endif
#include <KTp/contact-info-dialog.h>
+#include <KTp/OTR/constants.h>
#define PREFERRED_RFB_HANDLER "org.freedesktop.Telepathy.Client.krfb_rfb_handler"
@@ -969,7 +969,7 @@ void ChatWindow::onOtrStatusChanged(OtrStatus status)
switch(status.otrTrustLevel()) {
- case Tp::OTRTrustLevelNotPrivate:
+ case KTp::OTRTrustLevelNotPrivate:
m_otrActionMenu->setIcon(KIcon(QLatin1String("object-unlocked")));
m_otrActionMenu->setToolTip(i18n("Not private"));
srAction->setEnabled(true);
@@ -978,7 +978,7 @@ void ChatWindow::onOtrStatusChanged(OtrStatus status)
authenticateBuddyAction->setEnabled(false);
return;
- case Tp::OTRTrustLevelUnverified:
+ case KTp::OTRTrustLevelUnverified:
m_otrActionMenu->setIcon(KIcon(QLatin1String("object-locked-unverified")));
m_otrActionMenu->setToolTip(i18n("Unverified"));
srAction->setEnabled(true);
@@ -987,7 +987,7 @@ void ChatWindow::onOtrStatusChanged(OtrStatus status)
authenticateBuddyAction->setEnabled(true);
return;
- case Tp::OTRTrustLevelPrivate:
+ case KTp::OTRTrustLevelPrivate:
m_otrActionMenu->setIcon(KIcon(QLatin1String("object-locked-verified")));
m_otrActionMenu->setToolTip(i18n("Private"));
srAction->setEnabled(true);
@@ -996,7 +996,7 @@ void ChatWindow::onOtrStatusChanged(OtrStatus status)
authenticateBuddyAction->setEnabled(true);
return;
- case Tp::OTRTrustLevelFinished:
+ case KTp::OTRTrustLevelFinished:
m_otrActionMenu->setIcon(KIcon(QLatin1String("object-locked-finished")));
m_otrActionMenu->setToolTip(i18n("Finished"));
srAction->setEnabled(true);
diff --git a/app/main.cpp b/app/main.cpp
index b66348c..ee073e6 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -18,7 +18,6 @@
*/
#include "chat-window.h"
-#include "otr-types.h"
#include "telepathy-chat-ui.h"
#include "defines.h"
@@ -34,6 +33,7 @@
#include <TelepathyQt/AccountManager>
#include <KTp/core.h>
+#include <KTp/OTR/types.h>
#include <KAboutData>
#include <KCmdLineArgs>
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
KCmdLineArgs::init(argc, argv, &aboutData);
Tp::registerTypes();
- Tp::registerOtrTypes();
+ KTp::registerOtrTypes();
Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
channelFactory->addCommonFeatures(Tp::Channel::FeatureCore);
diff --git a/cmake/modules/FindKTp.cmake b/cmake/modules/FindKTp.cmake
index 4c6f7a6..d059592 100644
--- a/cmake/modules/FindKTp.cmake
+++ b/cmake/modules/FindKTp.cmake
@@ -5,6 +5,7 @@
# KTP_MODELS_LIBRARIES
# KTP_WIDGETS_LIBRARIES
# KTP_LOGGER_LIBRARIES
+# KTP_OTR_LIBRARIES
# Copyright (c) 2011, Dario Freddi <drf at kde.org>
#
@@ -30,6 +31,7 @@ find_library(KTP_LIBRARIES NAMES ktpcommoninternalsprivate )
find_library(KTP_MODELS_LIBRARIES NAMES ktpmodelsprivate )
find_library(KTP_WIDGETS_LIBRARIES NAMES ktpwidgetsprivate )
find_library(KTP_LOGGER_LIBRARIES NAMES ktploggerprivate )
+find_library(KTP_OTR_LIBRARIES NAMES ktpotrprivate )
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(KTp DEFAULT_MSG
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index 3c42887..e1c6816 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -47,6 +47,7 @@ target_link_libraries(kcm_ktp_chat_otr
${KDE4_KDEUI_LIBS}
${KDE4_KUTILS_LIBS}
${KTP_LIBRARIES}
+ ${KTP_OTR_LIBRARIES}
${TELEPATHY_QT4_LIBRARIES}
ktpchat
)
diff --git a/config/otr-config.cpp b/config/otr-config.cpp
index c84a681..639ded9 100644
--- a/config/otr-config.cpp
+++ b/config/otr-config.cpp
@@ -19,7 +19,8 @@
#include "otr-config.h"
#include "ui_otr-config.h"
-#include "otr-types.h"
+
+#include <KTp/OTR/types.h>
#include <QLatin1String>
#include <KDebug>
@@ -48,10 +49,10 @@ OTRConfig::OTRConfig(QWidget *parent, const QVariantList& args)
ui->setupUi(this);
- ui->policyGroupButtons->setId(ui->rbAlways, Tp::OTRPolicyAlways);
- ui->policyGroupButtons->setId(ui->rbOpportunistic, Tp::OTRPolicyOpportunistic);
- ui->policyGroupButtons->setId(ui->rbManual, Tp::OTRPolicyManual);
- ui->policyGroupButtons->setId(ui->rbNever, Tp::OTRPolicyNever);
+ ui->policyGroupButtons->setId(ui->rbAlways, KTp::OTRPolicyAlways);
+ ui->policyGroupButtons->setId(ui->rbOpportunistic, KTp::OTRPolicyOpportunistic);
+ ui->policyGroupButtons->setId(ui->rbManual, KTp::OTRPolicyManual);
+ ui->policyGroupButtons->setId(ui->rbNever, KTp::OTRPolicyNever);
ui->tbFingerprints->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tbFingerprints, SIGNAL(customContextMenuRequested(QPoint)), SLOT(onFpTableMenuRequested(QPoint)));
@@ -120,11 +121,11 @@ void OTRConfig::loadFingerprints()
return;
}
- const Tp::FingerprintInfoList fingerprints = ps->knownFingerprints(currentAccount());
+ const KTp::FingerprintInfoList fingerprints = ps->knownFingerprints(currentAccount());
kDebug() << fingerprints.size();
ui->tbFingerprints->setRowCount(fingerprints.size());
int i = 0;
- Q_FOREACH(const Tp::FingerprintInfo &fp, fingerprints) {
+ Q_FOREACH(const KTp::FingerprintInfo &fp, fingerprints) {
ui->tbFingerprints->setItem(i, 0, new QTableWidgetItem(fp.contactName));
ui->tbFingerprints->setItem(i, 1, new QTableWidgetItem(fp.fingerprint));
ui->tbFingerprints->setItem(i, 2, new QTableWidgetItem(fp.isVerified ? i18n("yes") : i18n("no")));
@@ -160,7 +161,7 @@ void OTRConfig::changeEvent(QEvent* e)
void OTRConfig::onRadioSelected(int id)
{
kDebug();
- policy = static_cast<Tp::OTRPolicy>(id);
+ policy = static_cast<KTp::OTRPolicy>(id);
Q_EMIT changed(true);
}
@@ -204,7 +205,7 @@ void OTRConfig::onPolicyGet(Tp::PendingOperation *getOp)
bt->setChecked(false);
}
ui->policyGroupButtons->button(id)->setChecked(true);
- policy = static_cast<Tp::OTRPolicy>(id);
+ policy = static_cast<KTp::OTRPolicy>(id);
}
}
diff --git a/config/otr-config.h b/config/otr-config.h
index 5b0b781..c11166e 100644
--- a/config/otr-config.h
+++ b/config/otr-config.h
@@ -21,8 +21,10 @@
#ifndef OTR_CONFIG_H
#define OTR_CONFIG_H
-#include "otr-constants.h"
#include "proxy-service.h"
+#include "types.h"
+
+#include <KTp/OTR/constants.h>
#include <KCModule>
#include <QList>
@@ -73,7 +75,7 @@ private:
Ui::OTRConfigUi *ui;
Tp::AccountManagerPtr am;
QList<Tp::AccountPtr> accounts;
- Tp::OTRPolicy policy;
+ KTp::OTRPolicy policy;
ProxyServicePtr ps;
QMenu *fpCtxMenu;
};
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 796ff1b..fcdd6d7 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -17,12 +17,8 @@ set(ktpchat_SRCS
contact-delegate.cpp
notify-filter.cpp
text-chat-config.cpp
- otr-types.cpp
- channel-adapter.cpp
- otr-channel-proxy.cpp
- proxy-service-interface.cpp
proxy-service.cpp
- otr-utils.cpp
+ otr-status.cpp
authenticationwizard.cpp
otr-notifications.cpp
)
@@ -45,6 +41,7 @@ target_link_libraries(ktpchat
${KDE4_KEMOTICONS_LIBS}
${KTP_LIBRARIES}
${KTP_LOGGER_LIBRARIES}
+ ${KTP_OTR_LIBRARIES}
ktpimagesharer
)
install(TARGETS ktpchat ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/lib/authenticationwizard.cpp b/lib/authenticationwizard.cpp
index 8f07d71..0e95422 100644
--- a/lib/authenticationwizard.cpp
+++ b/lib/authenticationwizard.cpp
@@ -20,7 +20,8 @@
*************************************************************************/
#include "authenticationwizard.h"
-#include "channel-adapter.h"
+
+#include <KTp/OTR/channel-adapter.h>
#include <KDebug>
#include <KLocale>
@@ -71,7 +72,7 @@ namespace
}
AuthenticationWizard::AuthenticationWizard(
- ChannelAdapter *chAdapter,
+ KTp::ChannelAdapter *chAdapter,
const QString &contact,
QWidget *parent,
bool initiate,
@@ -119,7 +120,7 @@ AuthenticationWizard::~AuthenticationWizard()
wizardList.removeAll(this);
}
-AuthenticationWizard *AuthenticationWizard::findWizard(ChannelAdapter *chAdapter)
+AuthenticationWizard *AuthenticationWizard::findWizard(KTp::ChannelAdapter *chAdapter)
{
for(int i = 0; i < wizardList.size(); i++) {
if(wizardList.at(i)->chAdapter == chAdapter) {
@@ -247,7 +248,7 @@ QWizardPage *AuthenticationWizard::createMVPage()
cbManualAuth->addItem(i18nc("@item:inlistbox ...verified that", "I have"));
cbManualAuth->setSizeAdjustPolicy(QComboBox::AdjustToContents);
- if(chAdapter->otrTrustLevel() == Tp::OTRTrustLevelPrivate) {
+ if(chAdapter->otrTrustLevel() == KTp::OTRTrustLevelPrivate) {
cbManualAuth->setCurrentIndex(1);
} else {
cbManualAuth->setCurrentIndex(0);
diff --git a/lib/authenticationwizard.h b/lib/authenticationwizard.h
index d1cb5f7..15ab2ca 100644
--- a/lib/authenticationwizard.h
+++ b/lib/authenticationwizard.h
@@ -29,14 +29,17 @@
#include <QWizard>
#include <QRadioButton>
-class ChannelAdapter;
+namespace KTp
+{
+ class ChannelAdapter;
+}
class AuthenticationWizard: public QWizard
{
Q_OBJECT
public:
explicit AuthenticationWizard(
- ChannelAdapter *chAdapter,
+ KTp::ChannelAdapter *chAdapter,
const QString &contact,
QWidget *parent = 0,
bool initiate = true,
@@ -44,7 +47,7 @@ public:
~AuthenticationWizard();
- static AuthenticationWizard *findWizard(ChannelAdapter *chAdapter);
+ static AuthenticationWizard *findWizard(KTp::ChannelAdapter *chAdapter);
void nextState();
void finished(bool success);
void aborted();
@@ -65,7 +68,7 @@ private:
Page_Final
};
- ChannelAdapter *chAdapter;
+ KTp::ChannelAdapter *chAdapter;
const QString contact;
QString question;
diff --git a/lib/channel-adapter.cpp b/lib/channel-adapter.cpp
deleted file mode 100644
index f599b2c..0000000
--- a/lib/channel-adapter.cpp
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- Copyright (C) 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) any later version.
-
- 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 "channel-adapter.h"
-#include "chat-widget.h"
-#include "otr-channel-proxy.h"
-#include "otr-utils.h"
-#include "otr-constants.h"
-
-#include <KDebug>
-
-#include <TelepathyQt/SharedPtr>
-#include <QMap>
-#include <QGenericArgument>
-
-typedef QSharedPointer<Tp::Client::ChannelProxyInterfaceOTRInterface> OTRProxyPtr;
-
-namespace
-{
- int getId(const Tp::ReceivedMessage &recvMes)
- {
- return recvMes.header()[QLatin1String("pending-message-id")].variant().toUInt(NULL);
- }
-}
-
-class OTRMessage : public Tp::ReceivedMessage
-{
- public:
- OTRMessage(const Tp::ReceivedMessage &recMes)
- : Tp::ReceivedMessage(recMes)
- {
- }
-
- OTRMessage(const Tp::MessagePartList &message, const Tp::TextChannelPtr channel)
- : Tp::ReceivedMessage(message, channel)
- {
- setSender(channel->targetContact());
- }
-
- bool hasId() const
- {
- return header().contains(QLatin1String("pending-message-id"));
- }
-
- int getId() const
- {
- return ::getId(*this);
- }
-
- void setId(int id)
- {
- header()[QLatin1String("pending-message-id")] = QDBusVariant(id);
- }
-
- void setSender(const Tp::ContactPtr &contact)
- {
- ReceivedMessage::setSender(contact);
- }
-};
-
-struct ChannelAdapter::Private
-{
- Private()
- : otrConnected(false),
- trustLevel(Tp::OTRTrustLevelNotPrivate)
- {
- }
-
- Tp::TextChannelPtr textChannel;
- OTRProxyPtr otrProxy;
-
- bool otrConnected;
- Tp::OTRTrustLevel trustLevel;
- QString remoteFp;
-
- QMap<uint, OTRMessage> messages;
- QMap<uint, OTRMessage> otrEvents;
-};
-
-ChannelAdapter::ChannelAdapter(const Tp::TextChannelPtr &textChannel, QObject *parent)
- : QObject(parent),
- d(new Private())
-{
- setChannel(textChannel);
-}
-
-ChannelAdapter::~ChannelAdapter()
-{
- delete d;
-}
-
-bool ChannelAdapter::isValid() const
-{
- return d->textChannel->isValid();
-}
-
-void ChannelAdapter::setChannel(const Tp::TextChannelPtr &textChannel)
-{
- d->textChannel = textChannel;
- QDBusConnection dbusConnection = textChannel->dbusConnection();
- if(textChannel->targetHandleType() != Tp::HandleTypeContact ||
- !dbusConnection.interface()->isServiceRegistered(KTP_PROXY_BUS_NAME))
- {
- setupTextChannel();
- return;
- }
-
- QString otrProxyPath = Tp::Utils::getOtrProxyObjectPathFor(textChannel);
- d->otrProxy = OTRProxyPtr(new Tp::Client::ChannelProxyInterfaceOTRInterface(KTP_PROXY_BUS_NAME, otrProxyPath, this));
-
- if(!d->otrProxy->isValid()) {
- kDebug() << "No OTR proxy available for channel: " << textChannel->objectPath();
- setupTextChannel();
- return;
- }
-
- kDebug() << "Connecting to the OTR proxy: " << d->otrProxy->path();
- QDBusPendingReply<> connectResult = d->otrProxy->ConnectProxy();
- connectResult.waitForFinished();
- if(connectResult.isValid()) {
- setupOTRChannel();
- } else {
- kWarning() << "Could not connect to the proxy" << connectResult.error().message();
- setupTextChannel();
- }
-}
-
-Tp::TextChannelPtr ChannelAdapter::textChannel()
-{
- return d->textChannel;
-}
-
-void ChannelAdapter::setupTextChannel()
-{
- kDebug();
- connect(d->textChannel.data(), SIGNAL(messageReceived(Tp::ReceivedMessage)),
- SIGNAL(messageReceived(Tp::ReceivedMessage)));
- connect(d->textChannel.data(), SIGNAL(pendingMessageRemoved(Tp::ReceivedMessage)),
- SIGNAL(pendingMessageRemoved(Tp::ReceivedMessage)));
- connect(d->textChannel.data(), SIGNAL(messageSent(Tp::Message,Tp::MessageSendingFlags,QString)),
- SIGNAL(messageSent(Tp::Message,Tp::MessageSendingFlags,QString)));
-}
-
-void ChannelAdapter::setupOTRChannel()
-{
- kDebug();
- d->otrConnected = true;
- d->trustLevel = Tp::OTRTrustLevelNotPrivate;
-
- connect(d->otrProxy.data(), SIGNAL(SessionRefreshed()), SIGNAL(sessionRefreshed()));
- connect(d->otrProxy.data(), SIGNAL(MessageReceived(const Tp::MessagePartList&)),
- SLOT(onMessageReceived(const Tp::MessagePartList&)));
- connect(d->otrProxy.data(), SIGNAL(PendingMessagesRemoved(const Tp::UIntList&)),
- SLOT(onPendingMessagesRemoved(const Tp::UIntList&)));
- connect(d->otrProxy.data(), SIGNAL(MessageSent(const Tp::MessagePartList&, uint, const QString&)),
- SLOT(onMessageSent(const Tp::MessagePartList&, uint, const QString&)));
- connect(d->otrProxy.data(), SIGNAL(TrustLevelChanged(uint)), SLOT(onTrustLevelChanged(uint)));
-
- // smp protocol
- connect(d->otrProxy.data(), SIGNAL(PeerAuthenticationRequested(const QString&)),
- SLOT(onPeerAuthenticationRequested(const QString&)));
- connect(d->otrProxy.data(), SIGNAL(PeerAuthenticationConcluded(bool)),
- SIGNAL(peerAuthenticationConcluded(bool)));
- connect(d->otrProxy.data(), SIGNAL(PeerAuthenticationInProgress()),
- SIGNAL(peerAuthenticationInProgress()));
- connect(d->otrProxy.data(), SIGNAL(PeerAuthenticationAborted()),
- SIGNAL(peerAuthenticationAborted()));
- connect(d->otrProxy.data(), SIGNAL(PeerAuthenticationError()),
- SIGNAL(peerAuthenticationError()));
- connect(d->otrProxy.data(), SIGNAL(PeerAuthenticationCheated()),
- SIGNAL(peerAuthenticationCheated()));
-
- // initialize message queue;
- connect(d->otrProxy->requestPropertyPendingMessages(), SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onPendingMessagesPropertyGet(Tp::PendingOperation*)));
- // initialize trust level property
- connect(d->otrProxy->requestPropertyTrustLevel(), SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onTrustLevelPropertyGet(Tp::PendingOperation*)));
- // initialize remote fingerprint property
- connect(d->otrProxy->requestPropertyRemoteFingerprint(), SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onRemoteFingerprintPropertyGet(Tp::PendingOperation*)));
-}
-
-Tp::OTRTrustLevel ChannelAdapter::otrTrustLevel() const
-{
- return d->trustLevel;
-}
-
-void ChannelAdapter::onTrustLevelPropertyGet(Tp::PendingOperation *op)
-{
- if(op->isError()) {
- kWarning() << "Could not get property: TrustLevel";
- return;
- }
- // we must have received trust level changed signal before
- if(d->trustLevel != Tp::OTRTrustLevelNotPrivate) {
- return;
- }
- Tp::PendingVariant *pv = dynamic_cast<Tp::PendingVariant*>(op);
- d->trustLevel = static_cast<Tp::OTRTrustLevel>(pv->result().toUInt(NULL));
- Q_EMIT otrTrustLevelChanged(d->trustLevel, Tp::OTRTrustLevelNotPrivate);
-}
-
-bool ChannelAdapter::isOTRsuppored() const
-{
- return d->otrConnected;
-}
-
-void ChannelAdapter::initializeOTR()
-{
- kDebug() << "Initializing OTR session";
- d->otrProxy->Initialize();
-}
-
-void ChannelAdapter::stopOTR()
-{
- kDebug();
- d->otrProxy->Stop();
-}
-
-QString ChannelAdapter::remoteFingerprint() const
-{
- return d->remoteFp;
-}
-
-QDBusPendingReply<> ChannelAdapter::trustFingerprint(const QString &fingerprint, bool trust)
-{
- return d->otrProxy->TrustFingerprint(fingerprint, trust);
-}
-
-void ChannelAdapter::acknowledge(const QList<Tp::ReceivedMessage> &messages)
-{
- if(messages.isEmpty()) {
- return;
- }
-
- kDebug();
- if(isOTRsuppored()) {
- QList<Tp::ReceivedMessage> toAck;
- QList<Tp::ReceivedMessage> eventsToRemove;
-
- Q_FOREACH(const Tp::ReceivedMessage &mes, messages) {
- if(Tp::Utils::isOtrEvent(mes)) {
- d->otrEvents.remove(getId(mes));
- eventsToRemove << mes;
- } else {
- toAck << mes;
- }
- }
- d->otrProxy->AcknowledgePendingMessages(Tp::Utils::getPendingMessagesIDs(toAck));
- Q_FOREACH(const Tp::ReceivedMessage &mes, eventsToRemove) {
- Q_EMIT pendingMessageRemoved(mes);
- }
- } else {
- d->textChannel->acknowledge(messages);
- }
-}
-
-void ChannelAdapter::send(const QString& text, Tp::ChannelTextMessageType type, Tp::MessageSendingFlags flags)
-{
- if(isOTRsuppored()) {
- Tp::MessagePartList parts;
- parts << Tp::MessagePart() << Tp::MessagePart();
- parts[0].insert(QLatin1String("message-type"),
- QDBusVariant(type));
- parts[1].insert(QLatin1String("content-type"),
- QDBusVariant(QLatin1String("text/plain")));
- parts[1].insert(QLatin1String("content"), QDBusVariant(text));
-
- d->otrProxy->SendMessage(parts, (uint) flags);
- } else {
- d->textChannel->send(text, type, flags);
- }
-}
-
-bool ChannelAdapter::supportsMessageType(Tp::ChannelTextMessageType messageType) const
-{
- return d->textChannel->supportsMessageType(messageType);
-}
-
-QList<Tp::ChannelTextMessageType> ChannelAdapter::supportedMessageTypes() const
-{
- return d->textChannel->supportedMessageTypes();
-}
-
-QStringList ChannelAdapter::supportedContentTypes() const
-{
- return d->textChannel->supportedContentTypes();
-}
-
-Tp::MessagePartSupportFlags ChannelAdapter::messagePartSupport() const
-{
- return d->textChannel->messagePartSupport();
-}
-
-Tp::DeliveryReportingSupportFlags ChannelAdapter::deliveryReportingSupport() const
-{
- return d->textChannel->deliveryReportingSupport();
-}
-
-QList<Tp::ReceivedMessage> ChannelAdapter::messageQueue() const
-{
- if(isOTRsuppored()) {
- QList<Tp::ReceivedMessage> messages;
- Q_FOREACH(const Tp::ReceivedMessage &m, d->messages) {
- messages << m;
- }
- Q_FOREACH(const Tp::ReceivedMessage &m, d->otrEvents) {
- messages << m;
- }
- return messages;
- } else {
- return d->textChannel->messageQueue();
- }
-}
-
-void ChannelAdapter::onMessageReceived(const Tp::MessagePartList &message)
-{
- kDebug();
- OTRMessage recvMes(message, d->textChannel);
- if(recvMes.hasId()) {
- const int id = recvMes.getId();
- if(!d->messages.contains(id)) {
- d->messages.insert(id, recvMes);
- Q_EMIT messageReceived(recvMes);
- } else {
- kWarning() << "Message already in the queue. Id: " << id;
- }
- } else if (Tp::Utils::isOtrEvent(recvMes)) {
- const int id = d->otrEvents.size();
- recvMes.setId(d->otrEvents.size());
- d->otrEvents.insert(id, recvMes);
- Q_EMIT messageReceived(recvMes);
- } else {
- kWarning() << "Message has not id and is not an OTR event either";
- }
-}
-
-void ChannelAdapter::onPendingMessagesPropertyGet(Tp::PendingOperation *op)
-{
- kDebug();
- Tp::PendingVariant *variant = dynamic_cast<Tp::PendingVariant*>(op);
-
- if(!variant->isError()) {
- QDBusArgument dbusArgument = variant->result().value<QDBusArgument>();
- Tp::MessagePartListList pendingMessages;
- dbusArgument >> pendingMessages;
- Q_FOREACH(const Tp::MessagePartList &message, pendingMessages) {
- onMessageReceived(message);
- }
- } else {
- kWarning() << "Could not initialize message queue: " << variant->errorName() << " - "
- << variant->errorMessage();
- }
-}
-
-void ChannelAdapter::onRemoteFingerprintPropertyGet(Tp::PendingOperation *op)
-{
- kDebug();
- Tp::PendingVariant *variant = dynamic_cast<Tp::PendingVariant*>(op);
-
- if(!variant->isError()) {
- d->remoteFp = variant->result().toString();
- } else {
- kWarning() << "Could not get remote fingerprint: " << variant->errorName() << " - "
- << variant->errorMessage();
- }
-}
-
-void ChannelAdapter::onPendingMessagesRemoved(const Tp::UIntList &messageIDs)
-{
- kDebug();
- Q_FOREACH(uint id, messageIDs) {
- const QMap<uint, OTRMessage>::Iterator mIt = d->messages.find(id);
- if(mIt != d->messages.end()) {
- OTRMessage message = *mIt;
- d->messages.erase(mIt);
- Q_EMIT pendingMessageRemoved(message);
- } else {
- kWarning() << "No message to remove with id: " << id;
- }
- }
-}
-
-void ChannelAdapter::onMessageSent(const Tp::MessagePartList &content, uint flags, const QString &messageToken)
-{
- kDebug();
- OTRMessage message(content, d->textChannel);
- Q_EMIT messageSent(message, Tp::MessageSendingFlags(flags), messageToken);
-}
-
-void ChannelAdapter::onTrustLevelChanged(uint trustLevel)
-{
- Tp::OTRTrustLevel oldLevel = d->trustLevel;
- d->trustLevel = static_cast<Tp::OTRTrustLevel>(trustLevel);
- // get remote's fingerprint
- if(oldLevel == Tp::OTRTrustLevelNotPrivate) {
- connect(d->otrProxy->requestPropertyRemoteFingerprint(), SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onRemoteFingerprintPropertyGet(Tp::PendingOperation*)));
- }
-
- // it may be a new session and the fingerprint has to be updated
- if(d->trustLevel == Tp::OTRTrustLevelPrivate || d->trustLevel == Tp::OTRTrustLevelUnverified) {
- connect(d->otrProxy->requestPropertyRemoteFingerprint(), SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onRemoteFingerprintPropertyGet(Tp::PendingOperation*)));
- }
-
- Q_EMIT otrTrustLevelChanged(d->trustLevel, oldLevel);
-}
-
-void ChannelAdapter::onPeerAuthenticationRequested(const QString &question)
-{
- if(question.isEmpty()) {
- Q_EMIT peerAuthenticationRequestedSS();
- } else {
- 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
deleted file mode 100644
index b294b25..0000000
--- a/lib/channel-adapter.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- Copyright (C) 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) any later version.
-
- 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 CHANNEL_ADAPTER_HEADER
-#define CHANNEL_ADAPTER_HEADER
-
-#include "otr-types.h"
-#include "otr-utils.h"
-#include "otr-channel-proxy.h"
-
-#include <QObject>
-
-#include <TelepathyQt/Types>
-#include <TelepathyQt/TextChannel>
-#include <TelepathyQt/PendingOperation>
-#include <TelepathyQt/RefCounted>
-
-class ChatWidget;
-
-class ChannelAdapter : public QObject, public Tp::RefCounted
-{
- Q_OBJECT
-
- public:
- ChannelAdapter(const Tp::TextChannelPtr &textChannel, QObject *parent = 0);
- ~ChannelAdapter();
-
- Tp::TextChannelPtr textChannel();
-
- Tp::OTRTrustLevel otrTrustLevel() const;
- bool isOTRsuppored() const;
- QString remoteFingerprint() const;
- QDBusPendingReply<> trustFingerprint(const QString &fingerprint, bool trust);
-
- bool isValid() const;
-
- void initializeOTR();
- void stopOTR();
- /** question answer peer authentication */
- void startPeerAuthenticationQA(const QString &question, const QString &answer);
- /** shared secret peer authentication*/
- void startPeerAuthenticationSS(const QString &secret);
- void respondPeerAuthentication(const QString &secret);
- void abortPeerAuthentication();
-
- void acknowledge(const QList<Tp::ReceivedMessage> &messages);
- void send(const QString& text,
- Tp::ChannelTextMessageType type = Tp::ChannelTextMessageTypeNormal,
- Tp::MessageSendingFlags flags = 0);
-
- bool supportsMessageType(Tp::ChannelTextMessageType messageType) const;
- QList<Tp::ChannelTextMessageType> supportedMessageTypes() const;
- QStringList supportedContentTypes() const;
- Tp::MessagePartSupportFlags messagePartSupport() const;
- Tp::DeliveryReportingSupportFlags deliveryReportingSupport() const;
-
- QList<Tp::ReceivedMessage> messageQueue() const;
-
- private:
- void setChannel(const Tp::TextChannelPtr &textChannel);
- void setupOTRChannel();
- void setupTextChannel();
-
- private Q_SLOTS:
- void onTrustLevelPropertyGet(Tp::PendingOperation *op);
- void onPendingMessagesPropertyGet(Tp::PendingOperation *op);
- void onRemoteFingerprintPropertyGet(Tp::PendingOperation *op);
- void onMessageReceived(const Tp::MessagePartList &message);
- void onPendingMessagesRemoved(const Tp::UIntList &messageIDs);
- void onMessageSent(const Tp::MessagePartList &content, uint flags, const QString &messageToken);
- void onTrustLevelChanged(uint trustLevel);
- void onPeerAuthenticationRequested(const QString &question);
-
- Q_SIGNALS:
- void messageSent(const Tp::Message &message,
- Tp::MessageSendingFlags flags,
- const QString &sentMessageToken);
- void messageReceived(const Tp::ReceivedMessage &message);
- void pendingMessageRemoved( const Tp::ReceivedMessage &message);
-
- void otrTrustLevelChanged(Tp::OTRTrustLevel newStatus, Tp::OTRTrustLevel oldStatus);
- void sessionRefreshed();
- void peerAuthenticationRequestedQA(const QString &question);
- void peerAuthenticationRequestedSS();
- void peerAuthenticationConcluded(bool authenticated);
- void peerAuthenticationInProgress();
- void peerAuthenticationAborted();
- void peerAuthenticationError();
- void peerAuthenticationCheated();
-
- private:
- struct Private;
- friend struct Private;
- Private *d;
-};
-
-typedef Tp::SharedPtr<ChannelAdapter> ChannelAdapterPtr;
-
-#endif
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index dd3d9a0..42da6f1 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -29,7 +29,6 @@
#include "notify-filter.h"
#include "text-chat-config.h"
#include "contact-delegate.h"
-#include "channel-adapter.h"
#include "authenticationwizard.h"
#include "otr-notifications.h"
@@ -65,6 +64,8 @@
#include <KTp/message-processor.h>
#include <KTp/Logger/scrollback-manager.h>
#include <KTp/contact-info-dialog.h>
+#include <KTp/OTR/channel-adapter.h>
+#include <KTp/OTR/utils.h>
#include <sonnet/speller.h>
@@ -80,7 +81,7 @@ public:
ChatWidgetPrivate(const Tp::TextChannelPtr &textChannel) :
remoteContactChatState(Tp::ChannelChatStateInactive),
isGroupChat(false),
- channel(new ChannelAdapter(textChannel)),
+ channel(new KTp::ChannelAdapter(textChannel)),
contactsMenu(0),
fileResourceTransferMenu(0),
fileTransferMenuAction(0),
@@ -99,7 +100,7 @@ public:
QString contactName;
QString yourName;
QString currentKeyboardLayoutLanguage;
- ChannelAdapterPtr channel;
+ KTp::ChannelAdapterPtr channel;
Tp::AccountPtr account;
ShareProvider *shareProvider;
Ui::ChatWidget ui;
@@ -357,7 +358,7 @@ void ChatWidget::setTextChannel(const Tp::TextChannelPtr &newTextChannelPtr)
{
d->channel.reset();
- d->channel = ChannelAdapterPtr(new ChannelAdapter(newTextChannelPtr));
+ d->channel = KTp::ChannelAdapterPtr(new KTp::ChannelAdapter(newTextChannelPtr));
d->contactModel->setTextChannel(newTextChannelPtr);
// connect signals for the new textchannel
@@ -688,7 +689,7 @@ void ChatWidget::startOtrSession()
}
d->channel->initializeOTR();
- if(d->channel->otrTrustLevel() == Tp::OTRTrustLevelNotPrivate) {
+ if(d->channel->otrTrustLevel() == KTp::OTRTrustLevelNotPrivate) {
d->ui.chatArea->addStatusMessage(i18n("Attempting to start a private OTR session with %1", d->contactName));
}
else {
@@ -699,7 +700,7 @@ void ChatWidget::startOtrSession()
void ChatWidget::stopOtrSession()
{
kDebug();
- if(!d->channel->isOTRsuppored() || d->channel->otrTrustLevel() == Tp::OTRTrustLevelNotPrivate) {
+ if(!d->channel->isOTRsuppored() || d->channel->otrTrustLevel() == KTp::OTRTrustLevelNotPrivate) {
return;
}
if(!d->channel->isValid()) {
@@ -732,8 +733,8 @@ void ChatWidget::setupOTR()
{
kDebug();
- connect(d->channel.data(), SIGNAL(otrTrustLevelChanged(Tp::OTRTrustLevel, Tp::OTRTrustLevel)),
- SLOT(onOTRTrustLevelChanged(Tp::OTRTrustLevel, Tp::OTRTrustLevel)));
+ connect(d->channel.data(), SIGNAL(otrTrustLevelChanged(KTp::OTRTrustLevel, KTp::OTRTrustLevel)),
+ SLOT(onOTRTrustLevelChanged(KTp::OTRTrustLevel, KTp::OTRTrustLevel)));
connect(d->channel.data(), SIGNAL(sessionRefreshed()),
SLOT(onOTRsessionRefreshed()));
connect(d->channel.data(), SIGNAL(peerAuthenticationRequestedQA(const QString&)),
@@ -752,7 +753,7 @@ void ChatWidget::setupOTR()
SLOT(onPeerAuthenticationFailed()));
}
-void ChatWidget::onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTrustLevel previous)
+void ChatWidget::onOTRTrustLevelChanged(KTp::OTRTrustLevel trustLevel, KTp::OTRTrustLevel previous)
{
kDebug();
@@ -762,8 +763,8 @@ void ChatWidget::onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTru
d->hasNewOTRstatus = true;
switch(trustLevel) {
- case Tp::OTRTrustLevelUnverified:
- if(previous == Tp::OTRTrustLevelPrivate) {
+ case KTp::OTRTrustLevelUnverified:
+ if(previous == KTp::OTRTrustLevelPrivate) {
d->ui.chatArea->addStatusMessage(i18n("The OTR session is unverified now"));
}
else {
@@ -773,8 +774,8 @@ void ChatWidget::onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTru
}
}
break;
- case Tp::OTRTrustLevelPrivate:
- if(previous == Tp::OTRTrustLevelUnverified) {
+ case KTp::OTRTrustLevelPrivate:
+ if(previous == KTp::OTRTrustLevelUnverified) {
d->ui.chatArea->addStatusMessage(i18n("The OTR session is private now"));
}
else {
@@ -784,7 +785,7 @@ void ChatWidget::onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTru
}
}
break;
- case Tp::OTRTrustLevelFinished:
+ case KTp::OTRTrustLevelFinished:
d->ui.chatArea->addStatusMessage(i18n("%1 has ended the OTR session. You should do the same", d->contactName));
if(!this->isActiveWindow()) {
OTRNotifications::otrSessionFinished(this, d->channel->textChannel()->targetContact());
@@ -972,8 +973,8 @@ void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message, bool
d->notifyFilter->filterMessage(processedMessage,
KTp::MessageContext(d->account, d->channel->textChannel()));
}
- if(Tp::Utils::isOtrEvent(message)) {
- d->ui.chatArea->addStatusMessage(Tp::Utils::processOtrMessage(message));
+ if(KTp::Utils::isOtrEvent(message)) {
+ d->ui.chatArea->addStatusMessage(KTp::Utils::processOtrMessage(message));
} else {
d->ui.chatArea->addMessage(processedMessage);
}
@@ -1016,7 +1017,7 @@ void ChatWidget::chatViewReady()
void ChatWidget::sendMessage()
{
- if(d->channel->isOTRsuppored() && d->channel->otrTrustLevel() == Tp::OTRTrustLevelFinished) {
+ if(d->channel->isOTRsuppored() && d->channel->otrTrustLevel() == KTp::OTRTrustLevelFinished) {
d->ui.chatArea->addStatusMessage(i18n("%1 has already closed his/her private connection to you."
"Your message was not sent. Either end your private conversation, or restart it.", d->contactName));
return;
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index c18d8be..bf7292c 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -23,8 +23,8 @@
#define CHATWIDGET_H
#include "ktpchat_export.h"
-#include "otr-utils.h"
-#include "otr-types.h"
+#include "otr-status.h"
+#include "types.h"
#include <QtCore/QString>
#include <QtGui/QWidget>
@@ -38,6 +38,7 @@
#include <KTp/presence.h>
#include <KTp/message.h>
+#include <KTp/OTR/types.h>
class ChatSearchBar;
class ChatWidgetPrivate;
@@ -233,7 +234,7 @@ private Q_SLOTS:
void onShareProviderFinishedFailure(ShareProvider *provider, const QString &errorMessage);
void onSendFileClicked();
- void onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTrustLevel previous);
+ void onOTRTrustLevelChanged(KTp::OTRTrustLevel trustLevel, KTp::OTRTrustLevel previous);
void onOTRsessionRefreshed();
void onPeerAuthenticationRequestedQA(const QString &question);
void onPeerAuthenticationRequestedSS();
diff --git a/lib/otr-channel-proxy.cpp b/lib/otr-channel-proxy.cpp
deleted file mode 100644
index 893ea76..0000000
--- a/lib/otr-channel-proxy.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#define IN_TP_QT_HEADER
-#include "otr-channel-proxy.h"
-
-namespace Tp
-{
-namespace Client
-{
-
-ChannelProxyInterfaceOTRInterface::ChannelProxyInterfaceOTRInterface(const QString& busName, const QString& objectPath, QObject *parent)
- : Tp::AbstractInterface(busName, objectPath, staticInterfaceName(), QDBusConnection::sessionBus(), parent)
-{
-}
-
-ChannelProxyInterfaceOTRInterface::ChannelProxyInterfaceOTRInterface(const QDBusConnection& connection, const QString& busName, const QString& objectPath, QObject *parent)
- : Tp::AbstractInterface(busName, objectPath, staticInterfaceName(), connection, parent)
-{
-}
-
-ChannelProxyInterfaceOTRInterface::ChannelProxyInterfaceOTRInterface(Tp::DBusProxy *proxy)
- : Tp::AbstractInterface(proxy, staticInterfaceName())
-{
-}
-
-ChannelProxyInterfaceOTRInterface::ChannelProxyInterfaceOTRInterface(const Tp::AbstractInterface& mainInterface)
- : Tp::AbstractInterface(mainInterface.service(), mainInterface.path(), staticInterfaceName(), mainInterface.connection(), mainInterface.parent())
-{
-}
-
-ChannelProxyInterfaceOTRInterface::ChannelProxyInterfaceOTRInterface(const Tp::AbstractInterface& mainInterface, QObject *parent)
- : Tp::AbstractInterface(mainInterface.service(), mainInterface.path(), staticInterfaceName(), mainInterface.connection(), parent)
-{
-}
-
-void ChannelProxyInterfaceOTRInterface::invalidate(Tp::DBusProxy *proxy,
- const QString &error, const QString &message)
-{
- disconnect(this, SIGNAL(MessageSent(const Tp::MessagePartList&, uint, const QString&)), NULL, NULL);
- disconnect(this, SIGNAL(MessageReceived(const Tp::MessagePartList&)), NULL, NULL);
- disconnect(this, SIGNAL(PendingMessagesRemoved(const Tp::UIntList&)), NULL, NULL);
- disconnect(this, SIGNAL(PeerAuthenticationRequested(const QString&)), NULL, NULL);
- disconnect(this, SIGNAL(PeerAuthenticationConcluded(bool)), NULL, NULL);
- disconnect(this, SIGNAL(PeerAuthenticationInProgress()), NULL, NULL);
- disconnect(this, SIGNAL(PeerAuthenticationAborted()), NULL, NULL);
- disconnect(this, SIGNAL(PeerAuthenticationError()), NULL, NULL);
- disconnect(this, SIGNAL(PeerAuthenticationCheated()), NULL, NULL);
- disconnect(this, SIGNAL(SessionRefreshed()), NULL, NULL);
- disconnect(this, SIGNAL(TrustLevelChanged(uint)), NULL, NULL);
-
- Tp::AbstractInterface::invalidate(proxy, error, message);
-}
-}
-}
diff --git a/lib/otr-channel-proxy.h b/lib/otr-channel-proxy.h
deleted file mode 100644
index 98ae4bb..0000000
--- a/lib/otr-channel-proxy.h
+++ /dev/null
@@ -1,690 +0,0 @@
-/*
- * This file contains D-Bus client proxy classes generated by qt-client-gen.py.
- *
- * This file can be distributed under the same terms as the specification from
- * which it was generated.
- */
-
-#ifndef OTR_CHANNEL_PROXY_HEADER
-#define OTR_CHANNEL_PROXY_HEADER
-
-#include <TelepathyQt/Types>
-
-#include <QtGlobal>
-
-#include <QString>
-#include <QObject>
-#include <QVariant>
-
-#include <QDBusPendingReply>
-
-#include <TelepathyQt/AbstractInterface>
-#include <TelepathyQt/DBusProxy>
-#include <TelepathyQt/Global>
-
-namespace Tp
-{
-class PendingVariant;
-class PendingOperation;
-}
-
-namespace Tp
-{
-namespace Client
-{
-
-/**
- *
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list