Commit 02a86bdb authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use qCDebug

parent 85e2bd20
......@@ -5,7 +5,7 @@ add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
set(mailtransport_lib_srcs
${mailtransport_lib_srcs}
mailtransport_debug.cpp
transport.cpp
transportmanager.cpp
transporttype.cpp
......
......@@ -24,7 +24,7 @@
#include "transporttype.h"
#include "ui_addtransportdialog.h"
#include <QDebug>
#include "mailtransport_debug.h"
#include <QDialogButtonBox>
#include <QPushButton>
......@@ -169,7 +169,7 @@ void AddTransportDialog::accept()
using namespace Akonadi;
AgentInstanceCreateJob *cjob = new AgentInstanceCreateJob(d->selectedType().agentType());
if (!cjob->exec()) {
qWarning() << "Failed to create agent instance of type"
qCWarning(MAILTRANSPORT_LOG) << "Failed to create agent instance of type"
<< d->selectedType().agentType().identifier();
return;
}
......
......@@ -22,7 +22,7 @@
#include "outboxactions_p.h"
#include <QDebug>
#include "mailtransport_debug.h"
#include <agentmanager.h>
#include <collection.h>
......@@ -38,9 +38,9 @@ void DispatcherInterfacePrivate::massModifyResult(KJob *job)
{
// Nothing to do here, really. If the job fails, the user can retry it.
if (job->error()) {
qDebug() << "failed" << job->errorString();
qCDebug(MAILTRANSPORT_LOG) << "failed" << job->errorString();
} else {
qDebug() << "succeeded.";
qCDebug(MAILTRANSPORT_LOG) << "succeeded.";
}
}
......@@ -53,7 +53,7 @@ AgentInstance DispatcherInterface::dispatcherInstance() const
AgentInstance a =
AgentManager::self()->instance(QStringLiteral("akonadi_maildispatcher_agent"));
if (!a.isValid()) {
qWarning() << "Could not get MDA instance.";
qCWarning(MAILTRANSPORT_LOG) << "Could not get MDA instance.";
}
return a;
}
......
......@@ -19,7 +19,7 @@
#include "dispatchmodeattribute.h"
#include <QDebug>
#include "mailtransport_debug.h"
#include <attributefactory.h>
......@@ -86,7 +86,7 @@ void DispatchModeAttribute::deserialize(const QByteArray &data)
d->mDueDate = QDateTime::fromString(QString::fromLatin1(data.mid(5)), Qt::ISODate);
// NOTE: 5 is the strlen of "after".
} else {
qWarning() << "Failed to deserialize data [" << data << "]";
qCWarning(MAILTRANSPORT_LOG) << "Failed to deserialize data [" << data << "]";
}
}
......
......@@ -23,7 +23,7 @@
#include <itemfetchjob.h>
#include <itemfetchscope.h>
#include <QDebug>
#include "mailtransport_debug.h"
using namespace Akonadi;
......@@ -69,17 +69,17 @@ void FilterActionJob::Private::fetchResult(KJob *job)
void FilterActionJob::Private::traverseItems()
{
Q_ASSERT(functor);
qDebug() << "Traversing" << items.count() << "items.";
qCDebug(MAILTRANSPORT_LOG) << "Traversing" << items.count() << "items.";
foreach (const Item &item, items) {
if (functor->itemAccepted(item)) {
functor->itemAction(item, q);
qDebug() << "Added subjob for item" << item.id();
qCDebug(MAILTRANSPORT_LOG) << "Added subjob for item" << item.id();
}
}
if (q->subjobs().isEmpty()) {
qDebug() << "No subjobs; I am done";
qCDebug(MAILTRANSPORT_LOG) << "No subjobs; I am done";
} else {
qDebug() << "Have subjobs; Done when last of them is";
qCDebug(MAILTRANSPORT_LOG) << "Have subjobs; Done when last of them is";
}
q->commit();
}
......@@ -119,7 +119,7 @@ FilterActionJob::~FilterActionJob()
void FilterActionJob::doStart()
{
if (d->collection.isValid()) {
qDebug() << "Fetching collection" << d->collection.id();
qCDebug(MAILTRANSPORT_LOG) << "Fetching collection" << d->collection.id();
ItemFetchJob *fjob = new ItemFetchJob(d->collection, this);
Q_ASSERT(d->functor);
d->fetchScope = d->functor->fetchScope();
......
/* This file is part of the KDE project
Copyright (C) 2014 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "mailtransport_debug.h"
Q_LOGGING_CATEGORY(MAILTRANSPORT_LOG, "log_mailtransport")
/* This file is part of the KDE project
Copyright (C) 2014 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MAILTRANSPORT_DEBUG_H
#define MAILTRANSPORT_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(MAILTRANSPORT_LOG)
#endif
......@@ -23,7 +23,7 @@
#include "transportattribute.h"
#include "transportmanager.h"
#include <QDebug>
#include "mailtransport_debug.h"
#include <KLocalizedString>
#include <collection.h>
......
......@@ -19,6 +19,7 @@
#include "outboxactions_p.h"
#include "mailtransport_debug.h"
#include "dispatchmodeattribute.h"
#include "errorattribute.h"
......@@ -55,7 +56,7 @@ ItemFetchScope SendQueuedAction::fetchScope() const
bool SendQueuedAction::itemAccepted(const Item &item) const
{
if (!item.hasAttribute<DispatchModeAttribute>()) {
qWarning() << "Item doesn't have DispatchModeAttribute.";
qCWarning(MAILTRANSPORT_LOG) << "Item doesn't have DispatchModeAttribute.";
return false;
}
......@@ -137,12 +138,12 @@ ItemFetchScope DispatchManualTransportAction::fetchScope() const
bool DispatchManualTransportAction::itemAccepted(const Item &item) const
{
if (!item.hasAttribute<DispatchModeAttribute>()) {
qWarning() << "Item doesn't have DispatchModeAttribute.";
qCWarning(MAILTRANSPORT_LOG) << "Item doesn't have DispatchModeAttribute.";
return false;
}
if (!item.hasAttribute<TransportAttribute>()) {
qWarning() << "Item doesn't have TransportAttribute.";
qCWarning(MAILTRANSPORT_LOG) << "Item doesn't have TransportAttribute.";
return false;
}
......
......@@ -32,7 +32,7 @@
#include <QTimer>
// KDE
#include <QDebug>
#include "mailtransport_debug.h"
using namespace MailTransport;
......@@ -106,11 +106,11 @@ void ServerTestPrivate::finalResult()
return;
}
qDebug() << "Modes:" << connectionResults;
qDebug() << "Capabilities:" << capabilityResults;
qDebug() << "Normal:" << q->normalProtocols();
qDebug() << "SSL:" << q->secureProtocols();
qDebug() << "TLS:" << q->tlsProtocols();
qCDebug(MAILTRANSPORT_LOG) << "Modes:" << connectionResults;
qCDebug(MAILTRANSPORT_LOG) << "Capabilities:" << capabilityResults;
qCDebug(MAILTRANSPORT_LOG) << "Normal:" << q->normalProtocols();
qCDebug(MAILTRANSPORT_LOG) << "SSL:" << q->secureProtocols();
qCDebug(MAILTRANSPORT_LOG) << "TLS:" << q->tlsProtocols();
if (testProgress) {
testProgress->hide();
......@@ -146,7 +146,7 @@ QList< int > ServerTestPrivate::parseAuthenticationList(const QStringList &authe
}
// APOP is handled by handlePopConversation()
}
qDebug() << authentications << result;
qCDebug(MAILTRANSPORT_LOG) << authentications << result;
// LOGIN doesn't offer anything over PLAIN, requires more server
// roundtrips and is not an official SASL mechanism, but a MS-ism,
......@@ -161,7 +161,7 @@ QList< int > ServerTestPrivate::parseAuthenticationList(const QStringList &authe
void ServerTestPrivate::handleSMTPIMAPResponse(int type, const QString &text)
{
if (!text.contains(QLatin1String("AUTH"), Qt::CaseInsensitive)) {
qDebug() << "No authentication possible";
qCDebug(MAILTRANSPORT_LOG) << "No authentication possible";
return;
}
......@@ -185,7 +185,7 @@ void ServerTestPrivate::handleSMTPIMAPResponse(int type, const QString &text)
authenticationResults[type] << Transport::EnumAuthenticationType::CLEAR;
}
qDebug() << "For type" << type << ", we have:" << authenticationResults[type];
qCDebug(MAILTRANSPORT_LOG) << "For type" << type << ", we have:" << authenticationResults[type];
}
void ServerTestPrivate::slotNormalPossible()
......@@ -216,7 +216,7 @@ void ServerTestPrivate::sendInitialCapabilityQuery(MailTransport::Socket *socket
hostname += QLatin1String(".localnet");
}
}
qDebug() << "Hostname for EHLO is" << hostname;
qCDebug(MAILTRANSPORT_LOG) << "Hostname for EHLO is" << hostname;
socket->write(QLatin1String("EHLO ") + hostname);
}
......@@ -328,7 +328,7 @@ void ServerTestPrivate::slotReadNormal(const QString &text)
Q_ASSERT(encryptionMode != Transport::EnumEncryption::SSL);
static const int tlsHandshakeStage = 42;
qDebug() << "Stage" << normalStage + 1 << ", Mode" << encryptionMode;
qCDebug(MAILTRANSPORT_LOG) << "Stage" << normalStage + 1 << ", Mode" << encryptionMode;
// If we are in stage 42, we just do the handshake for TLS encryption and
// then reset the stage to -1, so that all authentication modes and
......@@ -373,7 +373,7 @@ void ServerTestPrivate::slotReadNormal(const QString &text)
// If the server announced that STARTTLS/STLS is available, we'll add TLS to the
// connection result, do the command and set the stage to 42 to start the handshake.
if (shouldStartTLS && encryptionMode == Transport::EnumEncryption::None) {
qDebug() << "Trying TLS...";
qCDebug(MAILTRANSPORT_LOG) << "Trying TLS...";
connectionResults << Transport::EnumEncryption::TLS;
if (testProtocol == POP_PROTOCOL) {
normalSocket->write(QLatin1String("STLS"));
......@@ -467,7 +467,7 @@ ServerTest::~ServerTest()
void ServerTest::start()
{
qDebug() << d;
qCDebug(MAILTRANSPORT_LOG) << d;
d->connectionResults.clear();
d->authenticationResults.clear();
......
......@@ -41,7 +41,7 @@
#include <QButtonGroup>
#include <KProtocolInfo>
#include <QDebug>
#include "mailtransport_debug.h"
#include <KMessageBox>
namespace
......@@ -349,7 +349,7 @@ void SMTPConfigWidget::ensureValidAuthSelection()
void SMTPConfigWidget::encryptionChanged(int enc)
{
Q_D(SMTPConfigWidget);
qDebug() << enc;
qCDebug(MAILTRANSPORT_LOG) << enc;
// adjust port
if (enc == Transport::EnumEncryption::SSL) {
......
......@@ -31,7 +31,7 @@
#include <KLocalizedString>
#include <QUrl>
#include <QDebug>
#include "mailtransport_debug.h"
#include <KIO/Job>
#include <KIO/Scheduler>
#include <KPasswordDialog>
......@@ -47,7 +47,7 @@ public:
void removeSlave(KIO::Slave *slave, bool disconnect = false)
{
qDebug() << "Removing slave" << slave << "from pool";
qCDebug(MAILTRANSPORT_LOG) << "Removing slave" << slave << "from pool";
const int slaveKey = slaves.key(slave);
if (slaveKey > 0) {
slaves.remove(slaveKey);
......@@ -107,7 +107,7 @@ SmtpJob::~SmtpJob()
if (!s_slavePool.isDestroyed()) {
s_slavePool->ref--;
if (s_slavePool->ref == 0) {
qDebug() << "clearing SMTP slave pool" << s_slavePool->slaves.count();
qCDebug(MAILTRANSPORT_LOG) << "clearing SMTP slave pool" << s_slavePool->slaves.count();
foreach (KIO::Slave *slave, s_slavePool->slaves) {
if (slave) {
KIO::Scheduler::disconnectSlave(slave);
......@@ -226,10 +226,10 @@ void SmtpJob::startSmtpJob()
slaveConfig.insert(QLatin1String("sasl"), transport()->authenticationTypeString());
}
d->slave = KIO::Scheduler::getConnectedSlave(destination, slaveConfig);
qDebug() << "Created new SMTP slave" << d->slave;
qCDebug(MAILTRANSPORT_LOG) << "Created new SMTP slave" << d->slave;
s_slavePool->slaves.insert(transport()->id(), d->slave);
} else {
qDebug() << "Re-using existing slave" << d->slave;
qCDebug(MAILTRANSPORT_LOG) << "Re-using existing slave" << d->slave;
}
KIO::TransferJob *job = KIO::put(destination, -1, KIO::HideProgressInfo);
......
......@@ -28,7 +28,7 @@
#include <QSslSocket>
// KDE
#include <QDebug>
#include "mailtransport_debug.h"
#include <ksocketfactory.h>
using namespace MailTransport;
......@@ -66,13 +66,13 @@ SocketPrivate::SocketPrivate(Socket *s) : q(s)
void SocketPrivate::slotConnected()
{
qDebug();
qCDebug(MAILTRANSPORT_LOG);
if (!secure) {
qDebug() << "normal connect";
qCDebug(MAILTRANSPORT_LOG) << "normal connect";
emit q->connected();
} else {
qDebug() << "encrypted connect";
qCDebug(MAILTRANSPORT_LOG) << "encrypted connect";
socket->startClientEncryption();
}
}
......@@ -80,7 +80,7 @@ void SocketPrivate::slotConnected()
void SocketPrivate::slotStateChanged(QAbstractSocket::SocketState state)
{
#ifdef comm_debug
qDebug() << "State is now:" << (int) state;
qCDebug(MAILTRANSPORT_LOG) << "State is now:" << (int) state;
#endif
if (state == QAbstractSocket::UnconnectedState) {
emit q->failed();
......@@ -90,7 +90,7 @@ void SocketPrivate::slotStateChanged(QAbstractSocket::SocketState state)
void SocketPrivate::slotModeChanged(QSslSocket::SslMode state)
{
#ifdef comm_debug
qDebug() << "Mode is now:" << state;
qCDebug(MAILTRANSPORT_LOG) << "Mode is now:" << state;
#endif
if (state == QSslSocket::SslClientMode) {
emit q->tlsDone();
......@@ -99,7 +99,7 @@ void SocketPrivate::slotModeChanged(QSslSocket::SslMode state)
void SocketPrivate::slotSocketRead()
{
qDebug();
qCDebug(MAILTRANSPORT_LOG);
if (!socket) {
return;
......@@ -112,7 +112,7 @@ void SocketPrivate::slotSocketRead()
}
#ifdef comm_debug
qDebug() << socket->isEncrypted() << m_msg.trimmed();
qCDebug(MAILTRANSPORT_LOG) << socket->isEncrypted() << m_msg.trimmed();
#endif
emit q->data(m_msg);
......@@ -121,7 +121,7 @@ void SocketPrivate::slotSocketRead()
void SocketPrivate::slotSslErrors(const QList<QSslError> &)
{
qDebug();
qCDebug(MAILTRANSPORT_LOG);
/* We can safely ignore the errors, we are only interested in the
capabilities. We're not sending auth info. */
socket->ignoreSslErrors();
......@@ -136,21 +136,21 @@ Socket::Socket(QObject *parent)
d->socket = 0;
d->port = 0;
d->secure = false;
qDebug();
qCDebug(MAILTRANSPORT_LOG);
}
Socket::~Socket()
{
qDebug();
qCDebug(MAILTRANSPORT_LOG);
delete d;
}
void Socket::reconnect()
{
qDebug() << "Connecting to:" << d->server << ":" << d->port;
qCDebug(MAILTRANSPORT_LOG) << "Connecting to:" << d->server << ":" << d->port;
#ifdef comm_debug
// qDebug() << d->protocol;
// qCDebug(MAILTRANSPORT_LOG) << d->protocol;
#endif
if (d->socket) {
......@@ -176,7 +176,7 @@ void Socket::reconnect()
void Socket::write(const QString &text)
{
// qDebug();
// qCDebug(MAILTRANSPORT_LOG);
// Eat things in the queue when there is no connection. We need
// to get a connection first don't we...
if (!d->socket || !available()) {
......@@ -186,7 +186,7 @@ void Socket::write(const QString &text)
QByteArray cs = (text + QLatin1String("\r\n")).toLatin1();
#ifdef comm_debug
qDebug() << "C :" << cs;
qCDebug(MAILTRANSPORT_LOG) << "C :" << cs;
#endif
d->socket->write(cs.data(), cs.size());
......@@ -194,14 +194,14 @@ void Socket::write(const QString &text)
bool Socket::available()
{
// qDebug();
// qCDebug(MAILTRANSPORT_LOG);
bool ok = d->socket && d->socket->state() == QAbstractSocket::ConnectedState;
return ok;
}
void Socket::startTLS()
{
qDebug() << objectName();
qCDebug(MAILTRANSPORT_LOG) << objectName();
d->socket->setProtocol(QSsl::TlsV1);
d->socket->startClientEncryption();
}
......
......@@ -27,7 +27,7 @@
#include <QTimer>
#include <KConfigGroup>
#include <QDebug>
#include "mailtransport_debug.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <KStringHandler>
......@@ -42,7 +42,7 @@ using namespace KWallet;
Transport::Transport(const QString &cfgGroup) :
TransportBase(cfgGroup), d(new TransportPrivate)
{
qDebug() << cfgGroup;
qCDebug(MAILTRANSPORT_LOG) << cfgGroup;
d->passwordLoaded = false;
d->passwordDirty = false;
d->storePasswordInFile = false;
......@@ -102,7 +102,7 @@ void Transport::updatePasswordState()
{
Transport *original = TransportManager::self()->transportById(id(), false);
if (original == this) {
qWarning() << "Tried to update password state of non-cloned transport.";
qCWarning(MAILTRANSPORT_LOG) << "Tried to update password state of non-cloned transport.";
return;
}
if (original) {
......@@ -110,7 +110,7 @@ void Transport::updatePasswordState()
d->passwordLoaded = original->d->passwordLoaded;
d->passwordDirty = original->d->passwordDirty;
} else {
qWarning() << "Transport with this ID not managed by transport manager.";
qCWarning(MAILTRANSPORT_LOG) << "Transport with this ID not managed by transport manager.";
}
}
......@@ -165,14 +165,14 @@ void Transport::usrRead()
using namespace Akonadi;
d->transportType = TransportType();
d->transportType.d->mType = type();
qDebug() << "type" << type();
qCDebug(MAILTRANSPORT_LOG) << "type" << type();
if (type() == EnumType::Akonadi) {
const AgentInstance instance = AgentManager::self()->instance(host());
if (!instance.isValid()) {
qWarning() << "Akonadi transport with invalid resource instance.";
qCWarning(MAILTRANSPORT_LOG) << "Akonadi transport with invalid resource instance.";
}
d->transportType.d->mAgentType = instance.type();
qDebug() << "agent type" << instance.type().name() << "id" << instance.type().identifier();
qCDebug(MAILTRANSPORT_LOG) << "agent type" << instance.type().name() << "id" << instance.type().identifier();
}
// Now we have the type and possibly agentType. Get the name, description
// etc. from TransportManager.
......@@ -181,7 +181,7 @@ void Transport::usrRead()
if (index != -1) {
d->transportType = types[ index ];
} else {
qWarning() << "Type unknown to manager.";
qCWarning(MAILTRANSPORT_LOG) << "Type unknown to manager.";
d->transportType.d->mName = i18nc("An unknown transport type", "Unknown");
}
}
......@@ -288,7 +288,7 @@ void Transport::readPassword()
QString::fromLatin1("transport-%1").arg(id()))) {
return;
}
qDebug() << "migrating password from kmail wallet";
qCDebug(MAILTRANSPORT_LOG) << "migrating password from kmail wallet";
KWallet::Wallet *wallet = TransportManager::self()->wallet();
if (wallet) {
QString pwd;
......@@ -326,7 +326,7 @@ bool Transport::needsWalletMigration() const
void Transport::migrateToWallet()
{
qDebug() << "migrating" << id() << "to wallet";
qCDebug(MAILTRANSPORT_LOG) << "migrating" << id() << "to wallet";
d->needsWalletMigration = false;
KConfigGroup group(config(), currentGroup());
group.deleteEntry("password");
......@@ -346,7 +346,7 @@ Transport *Transport::clone() const
TransportType Transport::transportType() const
{
if (!d->transportType.isValid()) {
qWarning() << "Invalid transport type.";
qCWarning(MAILTRANSPORT_LOG) << "Invalid transport type.";
}
return d->transportType;
}
......
......@@ -36,7 +36,7 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <QDebug>
#include "mailtransport_debug.h"
#include <KLocalizedString>
using namespace MailTransport;
......@@ -101,7 +101,7 @@ TransportConfigDialog::TransportConfigDialog(Transport *transport, QWidget *pare
break;
}
case Transport::EnumType::Akonadi: {
qWarning() << "Tried to configure an Akonadi transport.";
qCWarning(MAILTRANSPORT_LOG) << "Tried to configure an Akonadi transport.";
d->configWidget = new QLabel(i18n("This outgoing account cannot be configured."), this);
break;
}
......
......@@ -30,7 +30,7 @@
#include "transportmanager.h"
#include <KConfigDialogManager>
#include <QDebug>
#include "mailtransport_debug.h"
using namespace MailTransport;
......@@ -55,7 +55,7 @@ TransportConfigWidget::~ TransportConfigWidget()
void TransportConfigWidget::init(Transport *transport)
{
Q_D(TransportConfigWidget);
qDebug() << "this" << this << "d" << d;
qCDebug(MAILTRANSPORT_LOG) << "this" << this << "d" << d;
Q_ASSERT(transport);
d->transport = transport;
......@@ -76,6 +76,6 @@ void TransportConfigWidget::apply()
d->manager->updateSettings();
d->transport->forceUniqueName();
d->transport->save();
qDebug() << "Config written.";
qCDebug(MAILTRANSPORT_LOG) << "Config written.";
}
......@@ -29,7 +29,7 @@
#include <QHeaderView>
#include <QLineEdit>
#include <QDebug>
#include "mailtransport_debug.h"
#include <KLocalizedString>
using namespace MailTransport;
......@@ -64,7 +64,7 @@ void TransportListView::editItem(QTreeWidgetItem *item, int column)
const int id = item->data(0, Qt::UserRole).toInt();
Transport *t = TransportManager::self()->transportById(id);
if (!t) {
qWarning() << "Transport" << id << "not known by manager.";
qCWarning(MAILTRANSPORT_LOG) << "Transport" << id << "not known by manager.";
return;
}