Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[voicecall] Allow enabling logging without recompilation. Contributes…
… to JB#38541

Use logging categories for debug output so the level of debug output can
be configured on a target device.
  • Loading branch information
adenexter committed Jan 16, 2019
1 parent aa8876d commit 5f52ef1
Show file tree
Hide file tree
Showing 25 changed files with 126 additions and 110 deletions.
24 changes: 24 additions & 0 deletions lib/src/common.cpp
@@ -0,0 +1,24 @@
/*
* This file is a part of the Voice Call Manager Plugin project.
*
* Copyright (C) 2011-2012 Tom Swindell <t.swindell@rubyx.co.uk>
*
* 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

#include "common.h"

Q_LOGGING_CATEGORY(voicecall, "org.nemomobile.voicecall", QtWarningMsg)
14 changes: 5 additions & 9 deletions lib/src/common.h
Expand Up @@ -21,16 +21,12 @@
#ifndef COMMON_H
#define COMMON_H

#include <QDebug>
#include <QLoggingCategory>

#define WARNING_T(message) qWarning() << QString("VoiceCall W: %1: %2").arg(Q_FUNC_INFO).arg(message);
Q_DECLARE_LOGGING_CATEGORY(voicecall)

#ifndef WANT_TRACE
# define TRACE
# define DEBUG_T(message) if (false) { };
#else
# define TRACE qDebug() << QString("VoiceCall T: %1:%2").arg(Q_FUNC_INFO).arg(__LINE__) << this;
# define DEBUG_T(message) qDebug("%s", QString("VoiceCall D: %1: %2").arg(Q_FUNC_INFO).arg(message).toUtf8().constData());
#endif
#define WARNING_T(message, ...) qCWarning(voicecall, "%s " message, Q_FUNC_INFO, ##__VA_ARGS__)
#define TRACE qCInfo(voicecall, "%s:%d %p", Q_FUNC_INFO, __LINE__, this);
#define DEBUG_T(message, ...) qCDebug(voicecall, "%s " message, Q_FUNC_INFO, ##__VA_ARGS__)

#endif // COMMON_H
5 changes: 2 additions & 3 deletions lib/src/src.pro
Expand Up @@ -5,8 +5,6 @@ QT = core dbus

CONFIG += c++11

#DEFINES += WANT_TRACE

HEADERS += \
common.h \
voicecallmanagerinterface.h \
Expand All @@ -20,7 +18,8 @@ HEADERS += \
SOURCES += \
dbus/voicecallmanagerdbusadapter.cpp \
dbus/voicecallhandlerdbusadapter.cpp \
abstractvoicecallhandler.cpp
abstractvoicecallhandler.cpp \
common.cpp

target.path = /usr/lib

Expand Down
5 changes: 2 additions & 3 deletions plugins/declarative/src/src.pro
Expand Up @@ -5,8 +5,6 @@ QT = core dbus qml multimedia
TARGET = voicecall
uri = org.nemomobile.voicecall

#DEFINES += WANT_TRACE

PKGCONFIG += ngf-qt5

HEADERS += \
Expand All @@ -23,7 +21,8 @@ SOURCES += \
voicecallmanager.cpp \
voicecallmodel.cpp \
voicecallprovidermodel.cpp \
voicecallplugin.cpp
voicecallplugin.cpp \
../../../lib/src/common.cpp

OTHER_FILES += qmldir

Expand Down
6 changes: 3 additions & 3 deletions plugins/declarative/src/voicecallhandler.cpp
Expand Up @@ -59,7 +59,7 @@ VoiceCallHandler::VoiceCallHandler(const QString &handlerId, QObject *parent)
{
TRACE
Q_D(VoiceCallHandler);
DEBUG_T(QString("Creating D-Bus interface to: ") + handlerId);
DEBUG_T("Creating D-Bus interface to: %s", qPrintable(handlerId));
d->interface = new QDBusInterface("org.nemomobile.voicecall",
"/calls/" + handlerId,
"org.nemomobile.voicecall.VoiceCall",
Expand Down Expand Up @@ -445,10 +445,10 @@ void VoiceCallHandler::onPendingCallFinished(QDBusPendingCallWatcher *watcher)
QDBusPendingReply<bool> reply = *watcher;

if (reply.isError()) {
WARNING_T(QString::fromLatin1("Received error reply for member: %1 (%2)").arg(reply.reply().member()).arg(reply.error().message()));
WARNING_T("Received error reply for member: %s (%s)", qPrintable(reply.reply().member()), qPrintable(reply.error().message()));
emit this->error(reply.error().message());
watcher->deleteLater();
} else {
DEBUG_T(QString::fromLatin1("Received successful reply for member: %1").arg(reply.reply().member()));
DEBUG_T("Received successful reply for member: %s", qPrintable(reply.reply().member()));
}
}
9 changes: 7 additions & 2 deletions plugins/declarative/src/voicecallmanager.cpp
Expand Up @@ -190,6 +190,11 @@ bool VoiceCallManager::isSpeakerMuted() const
return d->interface->property("isSpeakerMuted").toBool();
}

bool VoiceCallManager::isDebugEnabled() const
{
return voicecall().isDebugEnabled();
}

void VoiceCallManager::dial(const QString &msisdn)
{
TRACE
Expand Down Expand Up @@ -343,7 +348,7 @@ void VoiceCallManager::onPendingCallFinished(QDBusPendingCallWatcher *watcher)
if (reply.isError()) {
emit this->error(reply.error().message());
} else {
DEBUG_T(QString("Received successful reply for member: ") + reply.reply().member());
DEBUG_T("Received successful reply for member: %s", qPrintable(reply.reply().member()));
}

watcher->deleteLater();
Expand All @@ -357,7 +362,7 @@ void VoiceCallManager::onPendingSilenceFinished(QDBusPendingCallWatcher *watcher
if (reply.isError()) {
emit this->error(reply.error().message());
} else {
DEBUG_T(QString("Received successful reply for member: ") + reply.reply().member());
DEBUG_T("Received successful reply for member: %s", qPrintable(reply.reply().member()));
}

watcher->deleteLater();
Expand Down
3 changes: 3 additions & 0 deletions plugins/declarative/src/voicecallmanager.h
Expand Up @@ -28,6 +28,7 @@ class VoiceCallManager : public QObject
Q_PROPERTY(bool isAudioRouted READ isAudioRouted WRITE setAudioRouted NOTIFY audioRoutedChanged)
Q_PROPERTY(bool isMicrophoneMuted READ isMicrophoneMuted WRITE setMuteMicrophone NOTIFY microphoneMutedChanged)
Q_PROPERTY(bool isSpeakerMuted READ isSpeakerMuted WRITE setMuteSpeaker NOTIFY speakerMutedChanged)
Q_PROPERTY(bool isDebugEnabled READ isDebugEnabled CONSTANT)

public:
explicit VoiceCallManager(QObject *parent = 0);
Expand All @@ -51,6 +52,8 @@ class VoiceCallManager : public QObject
bool isMicrophoneMuted() const;
bool isSpeakerMuted() const;

bool isDebugEnabled() const;

static QSharedPointer<VoiceCallHandler> getCallHandler(const QString &handlerId);

Q_SIGNALS:
Expand Down
2 changes: 1 addition & 1 deletion plugins/mce/src/mceplugin.cpp
Expand Up @@ -182,7 +182,7 @@ void McePlugin::onVoiceCallsChanged()
}
}

DEBUG_T("STATE: " + state);
DEBUG_T("STATE: %s", qPrintable(state));

message << state;
message << (isEmergency ? "emergency" : "normal");
Expand Down
2 changes: 0 additions & 2 deletions plugins/mce/src/src.pro
Expand Up @@ -5,8 +5,6 @@ QT += dbus

DEFINES += PLUGIN_NAME=\\\"mce-plugin\\\"

#DEFINES += WANT_TRACE

HEADERS += \
mceplugin.h

Expand Down
10 changes: 5 additions & 5 deletions plugins/ngf/src/ngfringtoneplugin.cpp
Expand Up @@ -122,7 +122,7 @@ void NgfRingtonePlugin::onVoiceCallAdded(AbstractVoiceCallHandler *handler)
Q_D(NgfRingtonePlugin);

++d->activeCallCount;
DEBUG_T(QString("Active call count: %1").arg(d->activeCallCount));
DEBUG_T("Active call count: %d", d->activeCallCount);

QObject::connect(handler, SIGNAL(statusChanged(VoiceCallStatus)), SLOT(onVoiceCallStatusChanged()));
QObject::connect(handler, SIGNAL(destroyed()), SLOT(onVoiceCallDestroyed()));
Expand All @@ -142,7 +142,7 @@ void NgfRingtonePlugin::onVoiceCallStatusChanged(AbstractVoiceCallHandler *handl
return;
}

DEBUG_T(QString("Voice call status changed to: ") + handler->statusText());
DEBUG_T("Voice call status changed to: ", qPrintable(handler->statusText()));

if (handler->status() != AbstractVoiceCallHandler::STATUS_INCOMING)
{
Expand Down Expand Up @@ -171,7 +171,7 @@ void NgfRingtonePlugin::onVoiceCallStatusChanged(AbstractVoiceCallHandler *handl
}

d->ringtoneEventId = d->ngf->play("ringtone", props);
DEBUG_T(QString("Playing ringtone, event id: %1").arg(d->ringtoneEventId));
DEBUG_T("Playing ringtone, event id: %u", d->ringtoneEventId);
}
}

Expand All @@ -193,7 +193,7 @@ void NgfRingtonePlugin::onVoiceCallDestroyed()
}

--d->activeCallCount;
DEBUG_T(QString("Active call count: %1").arg(d->activeCallCount));
DEBUG_T("Active call count: %d", d->activeCallCount);
}

void NgfRingtonePlugin::onSilenceRingtoneRequested()
Expand All @@ -211,7 +211,7 @@ void NgfRingtonePlugin::onConnectionStatus(bool connected)
{
Q_UNUSED(connected)
TRACE
DEBUG_T(QString("Connection to NGF daemon changed to: " + connected ? "connected" : "disconnected"));
DEBUG_T("Connection to NGF daemon changed to: %s", connected ? "connected" : "disconnected");
}

void NgfRingtonePlugin::onEventFailed(quint32 eventId)
Expand Down
2 changes: 0 additions & 2 deletions plugins/ngf/src/src.pro
Expand Up @@ -5,8 +5,6 @@ PKGCONFIG += ngf-qt5

DEFINES += PLUGIN_NAME=\\\"ngf-plugin\\\"

#DEFINES += WANT_TRACE

HEADERS += \
ngfringtoneplugin.h

Expand Down
4 changes: 2 additions & 2 deletions plugins/playback-manager/src/playbackmanagerplugin.cpp
Expand Up @@ -131,7 +131,7 @@ void PlaybackManagerPlugin::setMode(const QString &mode)
return;
}
else
DEBUG_T(on ? "Set PrivacyOverride true." : "Set PirvacyOverride false.");
DEBUG_T("Set PrivacyOverride %s.", on ? "true" : "false");

d->manager->onAudioModeChanged(mode);
}
Expand All @@ -152,7 +152,7 @@ void PlaybackManagerPlugin::setMuteMicrophone(bool on)
return;
}
else
DEBUG_T(on ? "Set Mute true." : "Set Mute false.");
DEBUG_T("Set Mute %s.", on ? "true" : "false");

d->manager->onMuteMicrophoneChanged(on);
}
Expand Down
2 changes: 0 additions & 2 deletions plugins/playback-manager/src/src.pro
Expand Up @@ -4,8 +4,6 @@ QT += dbus

DEFINES += PLUGIN_NAME=\\\"voicecall-playback-manager-plugin\\\"

#DEFINES += WANT_TRACE

HEADERS += \
playbackmanagerplugin.h

Expand Down
2 changes: 1 addition & 1 deletion plugins/providers/ofono/src/ofonovoicecallhandler.cpp
Expand Up @@ -125,7 +125,7 @@ QDateTime OfonoVoiceCallHandler::startedAt() const
{
TRACE
Q_D(const OfonoVoiceCallHandler);
DEBUG_T(QString("CALL START TIME: ") + d->ofonoVoiceCall->startTime());
DEBUG_T("CALL START TIME: %s", qPrintable(d->ofonoVoiceCall->startTime()));
return QDateTime::fromString(d->ofonoVoiceCall->startTime(), "");
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/providers/ofono/src/ofonovoicecallprovider.cpp
Expand Up @@ -54,7 +54,7 @@ class OfonoVoiceCallProviderPrivate

void debugMessage(const QString &message)
{
DEBUG_T(QString("OfonoVoiceCallProvider(") + ofonoModem->modemPath() + "): " + message);
DEBUG_T("OfonoVoiceCallProvider(%s): %s", qPrintable(ofonoModem->modemPath()), qPrintable(message));
}
};

Expand Down
Expand Up @@ -130,7 +130,7 @@ void OfonoVoiceCallProviderFactory::onModemAdded(const QString &modemPath)

if(d->providers.contains(modemPath))
{
WARNING_T(QString("OfonoVoiceCallProviderFactory: Modem already registered") + modemPath);
WARNING_T("OfonoVoiceCallProviderFactory: Modem already registered %s", qPrintable(modemPath));
return;
}

Expand Down
2 changes: 0 additions & 2 deletions plugins/providers/ofono/src/src.pro
Expand Up @@ -2,8 +2,6 @@ include(../../../plugin.pri)
TARGET = voicecall-ofono-plugin
QT += dbus

#DEFINES += WANT_TRACE

PKGCONFIG += qofono-qt5

HEADERS += \
Expand Down
32 changes: 16 additions & 16 deletions plugins/providers/telepathy/src/callchannelhandler.cpp
Expand Up @@ -269,20 +269,20 @@ void CallChannelHandler::onCallChannelChannelReady(Tp::PendingOperation *op)
Q_D(CallChannelHandler);
if(op->isError())
{
WARNING_T(QString("Operation failed: ") + op->errorName() + ": " + op->errorMessage());
WARNING_T("Operation failed: %s: %s", qPrintable(op->errorName()), qPrintable(op->errorMessage()));
emit this->error(QString("Telepathy Operation Failed: %1 - %2").arg(op->errorName(), op->errorMessage()));
return;
}

DEBUG_T("CallChannel Ready:");
qDebug() << "\tType:" << d->channel->channelType();
qDebug() << "\tInterfaces:" << d->channel->interfaces();
DEBUG_T("\tType: %s", qPrintable(d->channel->channelType()));
DEBUG_T("\tInterfaces: %s", qPrintable(d->channel->interfaces().join(QLatin1String(", "))));

DEBUG_T(QString("\tTransport: %1").arg(d->channel->initialTransportType()));
DEBUG_T(QString("\tInitial Audio: %1").arg(d->channel->hasInitialAudio()));
DEBUG_T(QString("\tAudio Name: %1").arg(d->channel->initialAudioName()));
DEBUG_T(QString("\tInitial Video: %1").arg(d->channel->hasInitialVideo()));
DEBUG_T(QString("\tVideo Name: %1").arg(d->channel->initialVideoName()));
DEBUG_T("\tTransport: %u", d->channel->initialTransportType());
DEBUG_T("\tInitial Audio: %s", d->channel->hasInitialAudio() ? "true" : "false");
DEBUG_T("\tAudio Name: %s", qPrintable(d->channel->initialAudioName()));
DEBUG_T("\tInitial Video: %s", d->channel->hasInitialVideo() ? "true" : "false");
DEBUG_T("\tVideo Name: %s", qPrintable(d->channel->initialVideoName()));

QObject::connect(d->channel.data(),
SIGNAL(contentAdded(Tp::CallContentPtr)),
Expand Down Expand Up @@ -316,17 +316,17 @@ void CallChannelHandler::onCallChannelChannelReady(Tp::PendingOperation *op)
}

Tp::CallContents contents = d->channel->contents();
DEBUG_T(QString("number of contents: %1").arg(contents.size()));
DEBUG_T("number of contents: %d", contents.size());
if (contents.size() > 0) {
foreach (const Tp::CallContentPtr &content, contents) {
Q_ASSERT(!content.isNull());
DEBUG_T("Call Content");
Tp::CallStreams streams = content->streams();
foreach (const Tp::CallStreamPtr &stream, streams) {
DEBUG_T(QString(" Call stream: localSendingState=%1").arg(stream->localSendingState()));
DEBUG_T(QString(" members: %1").arg(stream.data()->remoteMembers().size()));
DEBUG_T(" Call stream: localSendingState=%1", qPrintable(stream->localSendingState()));
DEBUG_T(" members: %u", stream.data()->remoteMembers().size());
foreach(const Tp::ContactPtr contact, stream.data()->remoteMembers()) {
DEBUG_T(QString(" member %1").arg(contact->id()) + " remoteSendingState=" + stream->remoteSendingState(contact));
DEBUG_T(" member %s remoteSendingState=%s", qPrintable(contact->id()), qPrintable(stream->remoteSendingState(contact)));
}
//onStreamAdded(stream);
}
Expand Down Expand Up @@ -357,7 +357,7 @@ void CallChannelHandler::onCallChannelChannelInvalidated(Tp::DBusProxy *, const
TRACE
Q_D(CallChannelHandler);

DEBUG_T(QString("Channel invalidated: ") + errorName + ": " + errorMessage);
DEBUG_T("Channel invalidated: %s: %s", qPrintable(errorName), qPrintable(errorMessage));

// It seems to get called twice.
QObject::disconnect(d->channel.data(),
Expand Down Expand Up @@ -427,7 +427,7 @@ void CallChannelHandler::onCallChannelAcceptCallFinished(Tp::PendingOperation *o
TRACE
if(op->isError())
{
WARNING_T(QString("Operation failed: ") + op->errorName() + ": " + op->errorMessage());
WARNING_T("Operation failed: %s: %s", qPrintable(op->errorName()), qPrintable(op->errorMessage()));
emit this->error(QString("Telepathy Operation Failed: %1 - %2").arg(op->errorName(), op->errorMessage()));
emit this->invalidated(op->errorName(), op->errorMessage());
return;
Expand All @@ -441,7 +441,7 @@ void CallChannelHandler::onCallChannelHangupCallFinished(Tp::PendingOperation *o
TRACE
if(op->isError())
{
WARNING_T(QString("Operation failed: ") + op->errorName() + ": " + op->errorMessage());
WARNING_T("Operation failed: %s: %s", qPrintable(op->errorName()), qPrintable(op->errorMessage()));
emit this->error(QString("Telepathy Operation Failed: %1 - %2").arg(op->errorName(), op->errorMessage()));
emit this->invalidated(op->errorName(), op->errorMessage());
return;
Expand All @@ -457,7 +457,7 @@ void CallChannelHandler::onFarstreamCreateChannelFinished(Tp::PendingOperation *

if(op->isError())
{
WARNING_T(QString("Operation failed: ") + op->errorName() + ": " + op->errorMessage());
WARNING_T("Operation failed: %s: %s", qPrintable(op->errorName()), qPrintable(op->errorMessage()));
emit this->error(QString("Telepathy Operation Failed: %1 - %2").arg(op->errorName(), op->errorMessage()));
this->hangup();
return;
Expand Down

0 comments on commit 5f52ef1

Please sign in to comment.