Commit fdeb02ce authored by David Edmundson's avatar David Edmundson
Browse files

Notification dataengine debug category

Test Plan: Compiles

Reviewers: broulik

Reviewed By: broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D11774
parent c3a0a7aa
......@@ -9,6 +9,11 @@ set(notifications_engine_SRCS
notificationsanitizer.cpp
)
ecm_qt_declare_logging_category(notifications_engine_SRCS HEADER debug.h
IDENTIFIER NOTIFICATIONS
CATEGORY_NAME kde.dataengine.notifications`
DEFAULT_SEVERITY Info)
qt5_add_dbus_adaptor( notifications_engine_SRCS org.freedesktop.Notifications.xml notificationsengine.h NotificationsEngine )
add_library(plasma_engine_notifications MODULE ${notifications_engine_SRCS})
......@@ -32,7 +37,16 @@ install(FILES notifications.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/se
#unit test
set(notifications_test_SRCS
notificationsanitizer.cpp
notifications_test.cpp
)
ecm_qt_declare_logging_category(notifications_test_SRCS HEADER debug.h
IDENTIFIER NOTIFICATIONS
CATEGORY_NAME kde.dataengine.notifications`
DEFAULT_SEVERITY Info)
add_executable(notification_test notificationsanitizer.cpp notifications_test.cpp)
add_executable(notification_test ${notifications_test_SRCS})
target_link_libraries(notification_test Qt5::Test Qt5::Core)
ecm_mark_as_test(notification_test)
......@@ -21,13 +21,13 @@
#include <klocalizedstring.h>
#include <QDebug>
#include "debug.h"
void NotificationAction::start()
{
//qDebug() << "Trying to perform the action " << operationName() << " on " << destination();
//qDebug() << "actionId: " << parameters()["actionId"].toString();
//qDebug() << "params: " << parameters();
qCDebug(NOTIFICATIONS) << "Trying to perform the action " << operationName() << " on " << destination();
qCDebug(NOTIFICATIONS) << "actionId: " << parameters()["actionId"].toString();
qCDebug(NOTIFICATIONS) << "params: " << parameters();
if (!m_engine) {
setErrorText(i18n("The notification dataEngine is not set."));
......@@ -49,7 +49,7 @@ void NotificationAction::start()
}
if (operationName() == QLatin1String("invokeAction")) {
//qDebug() << "invoking action on " << id;
qCDebug(NOTIFICATIONS) << "invoking action on " << id;
emit m_engine->ActionInvoked(id, parameters()[QStringLiteral("actionId")].toString());
} else if (operationName() == QLatin1String("userClosed")) {
//userClosedNotification deletes the job, so we have to invoke it queued, in this case emitResult() can be called
......
......@@ -22,9 +22,10 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QRegularExpression>
#include <QDebug>
#include <QUrl>
#include "debug.h"
QString NotificationSanitizer::parse(const QString &text)
{
// replace all \ns with <br/>
......@@ -92,7 +93,7 @@ QString NotificationSanitizer::parse(const QString &text)
out.writeEndDocument();
if (r.hasError()) {
qWarning() << "Notification to send to backend contains invalid XML: "
qCWarning(NOTIFICATIONS) << "Notification to send to backend contains invalid XML: "
<< r.errorString() << "line" << r.lineNumber()
<< "col" << r.columnNumber();
}
......
......@@ -22,7 +22,6 @@
#include "notificationsadaptor.h"
#include "notificationsanitizer.h"
#include <QDebug>
#include <KConfigGroup>
#include <klocalizedstring.h>
#include <KSharedConfig>
......@@ -43,6 +42,8 @@
// for ::kill
#include <signal.h>
#include "debug.h"
NotificationsEngine::NotificationsEngine( QObject* parent, const QVariantList& args )
: Plasma::DataEngine( parent, args ), m_nextId( 1 ), m_alwaysReplaceAppsList({QStringLiteral("Clementine"), QStringLiteral("Spotify"), QStringLiteral("Amarok")})
{
......@@ -59,7 +60,7 @@ NotificationsEngine::NotificationsEngine( QObject* parent, const QVariantList& a
// It's not the same but check if it isn't plasma,
// we don't want to kill Plasma
if (pid != plasmaPidReply.value()) {
qDebug() << "Terminating current Notification service with pid" << pid;
qCDebug(NOTIFICATIONS) << "Terminating current Notification service with pid" << pid;
// Now finally terminate the service and register our own
::kill(pid, SIGTERM);
// Wait 3 seconds and then try registering it again
......@@ -72,7 +73,7 @@ NotificationsEngine::NotificationsEngine( QObject* parent, const QVariantList& a
const bool broadcastsEnabled = config.readEntry("ListenForBroadcasts", false);
if (broadcastsEnabled) {
qDebug() << "Notifications engine is configured to listen for broadcasts";
qCDebug(NOTIFICATIONS) << "Notifications engine is configured to listen for broadcasts";
QDBusConnection::systemBus().connect({}, {}, QStringLiteral("org.kde.BroadcastNotifications"),
QStringLiteral("Notify"), this, SLOT(onBroadcastNotification(QMap<QString,QVariant>)));
}
......@@ -102,7 +103,7 @@ bool NotificationsEngine::registerDBusService()
return true;
}
qDebug() << "Failed to register Notifications service";
qCInfo(NOTIFICATIONS) << "Failed to register Notifications service";
return false;
}
......@@ -132,7 +133,6 @@ static QImage decodeNotificationSpecImageHint(const QDBusArgument& arg)
arg.beginStructure();
arg >> width >> height >> rowStride >> hasAlpha >> bitsPerSample >> channels >> pixels;
arg.endStructure();
//qDebug() << width << height << rowStride << hasAlpha << bitsPerSample << channels;
#define SANITY_CHECK(condition) \
if (!(condition)) { \
......@@ -195,7 +195,7 @@ uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id,
{
foreach(NotificationInhibiton *ni, m_inhibitions) {
if (hints[ni->hint] == ni->value) {
qDebug() << "notification inhibited. Skipping";
qCDebug(NOTIFICATIONS) << "notification inhibited. Skipping";
return -1;
}
}
......@@ -214,9 +214,9 @@ uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id,
partOf = m_activeNotifications.key(app_name + summary).midRef(13).toUInt();
}
qDebug() << "Currrent active notifications:" << m_activeNotifications;
qDebug() << "Guessing partOf as:" << partOf;
qDebug() << " New Notification: " << summary << body << timeout << "& Part of:" << partOf;
qCDebug(NOTIFICATIONS) << "Currrent active notifications:" << m_activeNotifications;
qCDebug(NOTIFICATIONS) << "Guessing partOf as:" << partOf;
qCDebug(NOTIFICATIONS) << " New Notification: " << summary << body << timeout << "& Part of:" << partOf;
QString bodyFinal = NotificationSanitizer::parse(body);
QString summaryFinal = summary;
......@@ -434,7 +434,7 @@ QSharedPointer<NotificationInhibiton> NotificationsEngine::createInhibition(cons
void NotificationsEngine::onBroadcastNotification(const QMap<QString, QVariant> &properties)
{
qDebug() << "Received broadcast notification";
qCDebug(NOTIFICATIONS) << "Received broadcast notification";
const auto currentUserId = KUserId::currentEffectiveUserId().nativeId();
......@@ -448,7 +448,7 @@ void NotificationsEngine::onBroadcastNotification(const QMap<QString, QVariant>
});
if (it == userIds.constEnd()) {
qDebug() << "It is not meant for us, ignoring";
qCDebug(NOTIFICATIONS) << "It is not meant for us, ignoring";
return;
}
}
......
Supports Markdown
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