Commit fdba2456 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Drop KDELibs4Support from KTp::OTR

parent 0b3093e9
......@@ -15,7 +15,8 @@ add_library (KTpOTR SHARED
channel-proxy-interface.cpp
proxy-service-interface.cpp
types.cpp
utils.cpp)
utils.cpp
debug.cpp)
add_library(KTp::OTR ALIAS KTpOTR)
set_target_properties(KTpOTR PROPERTIES
......@@ -29,7 +30,6 @@ target_link_libraries (KTpOTR
PUBLIC
${TELEPATHY_QT5_LIBRARIES}
PRIVATE
KF5::KDELibs4Support
KF5::I18n
)
target_include_directories(KTpOTR PUBLIC ${TELEPATHY_QT5_INCLUDE_DIR}) # TODO: Remove when TelepathyQt exports include paths properly
......
......@@ -21,7 +21,7 @@
#include "utils.h"
#include "constants.h"
#include <KDebug>
#include <debug.h>
#include <TelepathyQt/SharedPtr>
#include <TelepathyQt/ReceivedMessage>
......@@ -123,18 +123,18 @@ void ChannelAdapter::setChannel(const Tp::TextChannelPtr &textChannel)
d->otrProxy = OTRProxyPtr(new KTp::Client::ChannelProxyInterfaceOTRInterface(KTP_PROXY_BUS_NAME, otrProxyPath, this));
if(!d->otrProxy->isValid()) {
kDebug() << "No OTR proxy available for channel: " << textChannel->objectPath();
qCDebug(KTP_OTR) << "No OTR proxy available for channel: " << textChannel->objectPath();
setupTextChannel();
return;
}
kDebug() << "Connecting to the OTR proxy: " << d->otrProxy->path();
qCDebug(KTP_OTR) << "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();
qCWarning(KTP_OTR) << "Could not connect to the proxy" << connectResult.error().message();
setupTextChannel();
}
}
......@@ -146,7 +146,6 @@ Tp::TextChannelPtr ChannelAdapter::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)),
......@@ -157,7 +156,6 @@ void ChannelAdapter::setupTextChannel()
void ChannelAdapter::setupOTRChannel()
{
kDebug();
d->otrConnected = true;
d->trustLevel = KTp::OTRTrustLevelNotPrivate;
......@@ -203,7 +201,7 @@ KTp::OTRTrustLevel ChannelAdapter::otrTrustLevel() const
void ChannelAdapter::onTrustLevelPropertyGet(Tp::PendingOperation *op)
{
if(op->isError()) {
kWarning() << "Could not get property: TrustLevel";
qCWarning(KTP_OTR) << "Could not get property: TrustLevel";
return;
}
// we must have received trust level changed signal before
......@@ -222,13 +220,12 @@ bool ChannelAdapter::isOTRsuppored() const
void ChannelAdapter::initializeOTR()
{
kDebug() << "Initializing OTR session";
qCDebug(KTP_OTR) << "Initializing OTR session";
d->otrProxy->Initialize();
}
void ChannelAdapter::stopOTR()
{
kDebug();
d->otrProxy->Stop();
}
......@@ -248,7 +245,6 @@ void ChannelAdapter::acknowledge(const QList<Tp::ReceivedMessage> &messages)
return;
}
kDebug();
if(isOTRsuppored()) {
QList<Tp::ReceivedMessage> toAck;
QList<Tp::ReceivedMessage> eventsToRemove;
......@@ -330,7 +326,6 @@ QList<Tp::ReceivedMessage> ChannelAdapter::messageQueue() const
void ChannelAdapter::onMessageReceived(const Tp::MessagePartList &message)
{
kDebug();
OTRMessage recvMes(message, d->textChannel);
if(recvMes.hasId()) {
const int id = recvMes.getId();
......@@ -338,7 +333,7 @@ void ChannelAdapter::onMessageReceived(const Tp::MessagePartList &message)
d->messages.insert(id, recvMes);
Q_EMIT messageReceived(recvMes);
} else {
kWarning() << "Message already in the queue. Id: " << id;
qCWarning(KTP_OTR) << "Message already in the queue. Id: " << id;
}
} else if (KTp::Utils::isOtrEvent(recvMes)) {
const int id = d->otrEvents.size();
......@@ -346,13 +341,12 @@ void ChannelAdapter::onMessageReceived(const Tp::MessagePartList &message)
d->otrEvents.insert(id, recvMes);
Q_EMIT messageReceived(recvMes);
} else {
kWarning() << "Message has not id and is not an OTR event either";
qCWarning(KTP_OTR) << "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()) {
......@@ -363,27 +357,25 @@ void ChannelAdapter::onPendingMessagesPropertyGet(Tp::PendingOperation *op)
onMessageReceived(message);
}
} else {
kWarning() << "Could not initialize message queue: " << variant->errorName() << " - "
qCWarning(KTP_OTR) << "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() << " - "
qCWarning(KTP_OTR) << "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()) {
......@@ -391,14 +383,13 @@ void ChannelAdapter::onPendingMessagesRemoved(const Tp::UIntList &messageIDs)
d->messages.erase(mIt);
Q_EMIT pendingMessageRemoved(message);
} else {
kWarning() << "No message to remove with id: " << id;
qCWarning(KTP_OTR) << "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);
}
......
/*
* Copyright (C) 2014 Martin Klapetek <mklapetek@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "debug.h"
Q_LOGGING_CATEGORY(KTP_OTR, "ktp-otr")
/*
* Copyright (C) 2014 Martin Klapetek <mklapetek@kde.org>
* Copyright (C) 2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef KTP_OTR_DEBUG_H
#define KTP_OTR_DEBUG_H
#include <QLoggingCategory>
// include the QDebug here so there doesn't have to
// be two debug includes in the files using qCDebug
#include <QDebug>
Q_DECLARE_LOGGING_CATEGORY(KTP_OTR)
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment