From 51af0ee921337ea3b5946caa2700d6a6ac2c5ad7 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 15 Dec 2014 14:43:55 +0100 Subject: [PATCH] Remove KDELibs4Support from KTp::Declarative It was only being used by KDebug and some headers. --- KTp/Declarative/CMakeLists.txt | 4 ++- KTp/Declarative/conversation.cpp | 13 ++++---- KTp/Declarative/conversations-model.cpp | 8 ++--- KTp/Declarative/debug.cpp | 20 ++++++++++++ KTp/Declarative/debug.h | 29 +++++++++++++++++ KTp/Declarative/messages-model.cpp | 38 +++++++++++------------ KTp/Declarative/pinned-contacts-model.cpp | 3 +- KTp/Declarative/telepathy-manager.cpp | 1 - 8 files changed, 82 insertions(+), 34 deletions(-) create mode 100644 KTp/Declarative/debug.cpp create mode 100644 KTp/Declarative/debug.h diff --git a/KTp/Declarative/CMakeLists.txt b/KTp/Declarative/CMakeLists.txt index 97d66f0..1dbafea 100644 --- a/KTp/Declarative/CMakeLists.txt +++ b/KTp/Declarative/CMakeLists.txt @@ -13,6 +13,7 @@ set (ktp_qml_plugin_SRCS contact-pin.cpp telepathy-manager.cpp qml-plugins.cpp + debug.cpp ) add_library (ktpqmlplugin SHARED ${ktp_qml_plugin_SRCS}) @@ -20,7 +21,8 @@ add_library (ktpqmlplugin SHARED ${ktp_qml_plugin_SRCS}) target_link_libraries (ktpqmlplugin Qt5::Qml - KF5::KDELibs4Support + KF5::WindowSystem + KF5::I18n KTp::CommonInternals KTp::Logger KTp::Models diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp index e575dcb..325b542 100644 --- a/KTp/Declarative/conversation.cpp +++ b/KTp/Declarative/conversation.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include "debug.h" #include "channel-delegator.h" @@ -50,7 +50,7 @@ Conversation::Conversation(const Tp::TextChannelPtr &channel, QObject(parent), d (new ConversationPrivate) { - kDebug(); + qCDebug(KTP_DECLARATIVE); d->account = account; connect(d->account.data(), SIGNAL(connectionChanged(Tp::ConnectionPtr)), SLOT(onAccountConnectionChanged(Tp::ConnectionPtr))); @@ -78,8 +78,7 @@ Conversation::Conversation(const Tp::TextChannelPtr &channel, Conversation::Conversation(QObject *parent) : QObject(parent) { - kError() << "Conversation should not be created directly. Use ConversationWatcher instead."; - Q_ASSERT(false); + qCCritical(KTP_DECLARATIVE) << "Conversation should not be created directly. Use ConversationWatcher instead."; } void Conversation::setTextChannel(const Tp::TextChannelPtr& channel) @@ -156,7 +155,7 @@ bool Conversation::isValid() void Conversation::onChannelInvalidated(Tp::DBusProxy *proxy, const QString &errorName, const QString &errorMessage) { - kDebug() << proxy << errorName << ":" << errorMessage; + qCDebug(KTP_DECLARATIVE) << proxy << errorName << ":" << errorMessage; d->valid = false; @@ -198,7 +197,7 @@ void Conversation::delegateToProperClient() void Conversation::requestClose() { - kDebug(); + qCDebug(KTP_DECLARATIVE); //removing from the model will delete this object closing the channel Q_EMIT conversationCloseRequested(); @@ -230,7 +229,7 @@ void Conversation::onChatPausedTimerExpired() Conversation::~Conversation() { - kDebug(); + qCDebug(KTP_DECLARATIVE); //if we are not handling the channel do nothing. if (!d->delegated) { d->messages->textChannel()->requestClose(); diff --git a/KTp/Declarative/conversations-model.cpp b/KTp/Declarative/conversations-model.cpp index fa9f237..b824878 100644 --- a/KTp/Declarative/conversations-model.cpp +++ b/KTp/Declarative/conversations-model.cpp @@ -21,7 +21,7 @@ #include "conversation.h" #include "messages-model.h" -#include +#include "debug.h" #include #include @@ -64,7 +64,7 @@ QVariant ConversationsModel::data(const QModelIndex &index, int role) const if (index.isValid()) { if (role == ConversationRole) { result = QVariant::fromValue(d->conversations[index.row()]); - kDebug() << "returning value " << result; + qCDebug(KTP_DECLARATIVE) << "returning value " << result; } } return result; @@ -104,7 +104,7 @@ void ConversationsModel::handleChannels(const Tp::MethodInvocationContextPtr<> & //find the relevant channelRequest Q_FOREACH(const Tp::ChannelRequestPtr channelRequest, channelRequests) { - kDebug() << channelRequest->hints().allHints(); + qCDebug(KTP_DECLARATIVE) << channelRequest->hints().allHints(); shouldDelegate = channelRequest->hints().hint(QLatin1String("org.freedesktop.Telepathy.ChannelRequest"), QLatin1String("DelegateToPreferredHandler")).toBool(); } @@ -172,7 +172,7 @@ void ConversationsModel::removeConversation(Conversation* conv) conv->deleteLater(); endRemoveRows(); } else { - kError() << "attempting to delete non-existent conversation"; + qWarning() << "attempting to delete non-existent conversation"; } } diff --git a/KTp/Declarative/debug.cpp b/KTp/Declarative/debug.cpp new file mode 100644 index 0000000..724e3f3 --- /dev/null +++ b/KTp/Declarative/debug.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2014 Martin Klapetek + * + * 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_DECLARATIVE, "ktp-declarative") diff --git a/KTp/Declarative/debug.h b/KTp/Declarative/debug.h new file mode 100644 index 0000000..f5dc09b --- /dev/null +++ b/KTp/Declarative/debug.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2014 Martin Klapetek + * Copyright (C) 2014 Aleix Pol Gonzalez + * + * 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_DECLARATIVE_DEBUG_H +#define KTP_DECLARATIVE_DEBUG_H + +#include +// include the QDebug here so there doesn't have to +// be two debug includes in the files using qCDebug +#include +Q_DECLARE_LOGGING_CATEGORY(KTP_DECLARATIVE) + +#endif diff --git a/KTp/Declarative/messages-model.cpp b/KTp/Declarative/messages-model.cpp index 52c4844..8810a34 100644 --- a/KTp/Declarative/messages-model.cpp +++ b/KTp/Declarative/messages-model.cpp @@ -22,7 +22,7 @@ #include -#include +#include "debug.h" #include #include @@ -67,7 +67,7 @@ MessagesModel::MessagesModel(const Tp::AccountPtr &account, QObject *parent) : QAbstractListModel(parent), d(new MessagesModelPrivate) { - kDebug(); + qCDebug(KTP_DECLARATIVE); QHash roles; roles[TextRole] = "text"; @@ -103,7 +103,7 @@ bool MessagesModel::verifyPendingOperation(Tp::PendingOperation *op) bool operationSucceeded = true; if (op->isError()) { - kWarning() << op->errorName() << "+" << op->errorMessage(); + qCWarning(KTP_DECLARATIVE) << op->errorName() << "+" << op->errorMessage(); operationSucceeded = false; } @@ -126,7 +126,7 @@ void MessagesModel::setupChannelSignals(const Tp::TextChannelPtr &channel) void MessagesModel::setTextChannel(const Tp::TextChannelPtr &channel) { Q_ASSERT(channel != d->textChannel); - kDebug(); + qCDebug(KTP_DECLARATIVE); setupChannelSignals(channel); if (d->textChannel) { @@ -161,7 +161,7 @@ void MessagesModel::setTextChannel(const Tp::TextChannelPtr &channel) void MessagesModel::onHistoryFetched(const QList &messages) { - kDebug() << "found" << messages.count() << "messages in history"; + qCDebug(KTP_DECLARATIVE) << "found" << messages.count() << "messages in history"; if (!messages.isEmpty()) { //Add all messages before the ones already present in the channel beginInsertRows(QModelIndex(), 0, messages.count() - 1); @@ -176,21 +176,21 @@ void MessagesModel::onHistoryFetched(const QList &messages) void MessagesModel::onMessageReceived(const Tp::ReceivedMessage &message) { int unreadCount = d->textChannel->messageQueue().size(); - kDebug() << "unreadMessagesCount =" << unreadCount; - kDebug() << "text =" << message.text(); - kDebug() << "messageType = " << message.messageType(); - kDebug() << "messageToken =" << message.messageToken(); + qCDebug(KTP_DECLARATIVE) << "unreadMessagesCount =" << unreadCount; + qCDebug(KTP_DECLARATIVE) << "text =" << message.text(); + qCDebug(KTP_DECLARATIVE) << "messageType = " << message.messageType(); + qCDebug(KTP_DECLARATIVE) << "messageToken =" << message.messageToken(); if (message.isDeliveryReport()) { d->textChannel->acknowledge(QList() << message); Tp::ReceivedMessage::DeliveryDetails deliveryDetails = message.deliveryDetails(); if(!deliveryDetails.hasOriginalToken()) { - kDebug() << "Delivery report without original message token received."; + qCDebug(KTP_DECLARATIVE) << "Delivery report without original message token received."; // Matching the delivery report to the original message is impossible without the token. return; } - kDebug() << "originalMessageToken =" << deliveryDetails.originalToken(); + qCDebug(KTP_DECLARATIVE) << "originalMessageToken =" << deliveryDetails.originalToken(); QPersistentModelIndex originalMessageIndex = d->messagesByMessageToken.value( deliveryDetails.originalToken()); @@ -200,7 +200,7 @@ void MessagesModel::onMessageReceived(const Tp::ReceivedMessage &message) } MessagePrivate &originalMessage = d->messages[originalMessageIndex.row()]; - kDebug() << "Got delivery status" << deliveryDetails.status() + qCDebug(KTP_DECLARATIVE) << "Got delivery status" << deliveryDetails.status() << "for message with text" << originalMessage.message.mainMessagePart(); originalMessage.deliveryReportReceiveTime = message.received(); switch(deliveryDetails.status()) { @@ -208,7 +208,7 @@ void MessagesModel::onMessageReceived(const Tp::ReceivedMessage &message) case Tp::DeliveryStatusTemporarilyFailed: originalMessage.deliveryStatus = DeliveryStatusFailed; if (deliveryDetails.hasDebugMessage()) { - kDebug() << "Delivery failure debug message:" << deliveryDetails.debugMessage(); + qCDebug(KTP_DECLARATIVE) << "Delivery failure debug message:" << deliveryDetails.debugMessage(); } break; case Tp::DeliveryStatusDelivered: @@ -245,7 +245,7 @@ void MessagesModel::onMessageSent(const Tp::Message &message, Tp::MessageSending int length = rowCount(); beginInsertRows(QModelIndex(), length, length); - kDebug() << "text =" << message.text(); + qCDebug(KTP_DECLARATIVE) << "text =" << message.text(); const KTp::Message &newMessage = KTp::MessageProcessor::instance()->processIncomingMessage( message, d->account, d->textChannel); @@ -309,7 +309,7 @@ QVariant MessagesModel::data(const QModelIndex &index, int role) const break; }; } else { - kError() << "Attempting to access data at invalid index (" << index << ")"; + qWarning() << "Attempting to access data at invalid index (" << index << ")"; } return result; @@ -324,7 +324,7 @@ int MessagesModel::rowCount(const QModelIndex &parent) const void MessagesModel::sendNewMessage(const QString &message) { if (message.isEmpty()) { - kWarning() << "Attempting to send empty string"; + qCWarning(KTP_DECLARATIVE) << "Attempting to send empty string"; } else { Tp::PendingOperation *op; QString modifiedMessage = message; @@ -365,7 +365,7 @@ void MessagesModel::acknowledgeAllMessages() { QList queue = d->textChannel->messageQueue(); - kDebug() << "Conversation Visible, Acknowledging " << queue.size() << " messages."; + qCDebug(KTP_DECLARATIVE) << "Conversation Visible, Acknowledging " << queue.size() << " messages."; d->textChannel->acknowledge(queue); Q_EMIT unreadCountChanged(queue.size()); @@ -373,7 +373,7 @@ void MessagesModel::acknowledgeAllMessages() void MessagesModel::setVisibleToUser(bool visible) { - kDebug() << visible; + qCDebug(KTP_DECLARATIVE) << visible; if (d->visible != visible) { d->visible = visible; @@ -392,7 +392,7 @@ bool MessagesModel::isVisibleToUser() const MessagesModel::~MessagesModel() { - kDebug(); + qCDebug(KTP_DECLARATIVE); delete d; } diff --git a/KTp/Declarative/pinned-contacts-model.cpp b/KTp/Declarative/pinned-contacts-model.cpp index 155624f..4914328 100644 --- a/KTp/Declarative/pinned-contacts-model.cpp +++ b/KTp/Declarative/pinned-contacts-model.cpp @@ -29,9 +29,8 @@ #include #include -#include #include -#include +#include "debug.h" #include "KTp/presence.h" #include "KTp/contact.h" diff --git a/KTp/Declarative/telepathy-manager.cpp b/KTp/Declarative/telepathy-manager.cpp index 0eef901..5630beb 100644 --- a/KTp/Declarative/telepathy-manager.cpp +++ b/KTp/Declarative/telepathy-manager.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include -- GitLab