Shortened log statements in NotificationManager
Copy/paste is evil
This commit is contained in:
parent
e578c6bef3
commit
65738a4ddf
1 changed files with 20 additions and 20 deletions
|
@ -28,9 +28,11 @@
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
|
|
||||||
|
#define LOG(x) qDebug() << "[NotificationManager]" << x
|
||||||
|
|
||||||
NotificationManager::NotificationManager(TDLibWrapper *tdLibWrapper, QObject *parent) : QObject(parent)
|
NotificationManager::NotificationManager(TDLibWrapper *tdLibWrapper, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Initializing...";
|
LOG("Initializing...");
|
||||||
this->tdLibWrapper = tdLibWrapper;
|
this->tdLibWrapper = tdLibWrapper;
|
||||||
this->ngfClient = new Ngf::Client(this);
|
this->ngfClient = new Ngf::Client(this);
|
||||||
|
|
||||||
|
@ -44,29 +46,28 @@ NotificationManager::NotificationManager(TDLibWrapper *tdLibWrapper, QObject *pa
|
||||||
connect(this->ngfClient, SIGNAL(eventPlaying(quint32)), this, SLOT(handleNgfEventPlaying(quint32)));
|
connect(this->ngfClient, SIGNAL(eventPlaying(quint32)), this, SLOT(handleNgfEventPlaying(quint32)));
|
||||||
|
|
||||||
if (this->ngfClient->connect()) {
|
if (this->ngfClient->connect()) {
|
||||||
qDebug() << "[NotificationManager] NGF Client successfully initialized...";
|
LOG("NGF Client successfully initialized...");
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "[NotificationManager] Failed to initialize NGF Client...";
|
LOG("Failed to initialize NGF Client...");
|
||||||
}
|
}
|
||||||
|
|
||||||
this->controlLedNotification(false);
|
this->controlLedNotification(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationManager::~NotificationManager()
|
NotificationManager::~NotificationManager()
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Destroying myself...";
|
LOG("Destroying myself...");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleUpdateActiveNotifications(const QVariantList notificationGroups)
|
void NotificationManager::handleUpdateActiveNotifications(const QVariantList notificationGroups)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Received active notifications, number of groups:" << notificationGroups.size();
|
LOG("Received active notifications, number of groups:" << notificationGroups.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleUpdateNotificationGroup(const QVariantMap notificationGroupUpdate)
|
void NotificationManager::handleUpdateNotificationGroup(const QVariantMap notificationGroupUpdate)
|
||||||
{
|
{
|
||||||
QString notificationGroupId = notificationGroupUpdate.value("notification_group_id").toString();
|
QString notificationGroupId = notificationGroupUpdate.value("notification_group_id").toString();
|
||||||
qDebug() << "[NotificationManager] Received notification group update, group ID:" << notificationGroupId;
|
LOG("Received notification group update, group ID:" << notificationGroupId);
|
||||||
QVariantMap notificationGroup = this->notificationGroups.value(notificationGroupId).toMap();
|
QVariantMap notificationGroup = this->notificationGroups.value(notificationGroupId).toMap();
|
||||||
|
|
||||||
QString chatId = notificationGroupUpdate.value("chat_id").toString();
|
QString chatId = notificationGroupUpdate.value("chat_id").toString();
|
||||||
|
@ -92,7 +93,7 @@ void NotificationManager::handleUpdateNotificationGroup(const QVariantMap notifi
|
||||||
|
|
||||||
// If we have deleted notifications, we need to update possibly existing ones
|
// If we have deleted notifications, we need to update possibly existing ones
|
||||||
if (!removedNotificationIds.isEmpty() && !activeNotifications.isEmpty()) {
|
if (!removedNotificationIds.isEmpty() && !activeNotifications.isEmpty()) {
|
||||||
qDebug() << "[NotificationManager] Some removals happend, but we have " << activeNotifications.size() << "existing notifications.";
|
LOG("Some removals happend, but we have" << activeNotifications.size() << "existing notifications.");
|
||||||
QVariantMap firstActiveNotification = activeNotifications.first().toMap();
|
QVariantMap firstActiveNotification = activeNotifications.first().toMap();
|
||||||
activeNotifications.remove(firstActiveNotification.value("id").toString());
|
activeNotifications.remove(firstActiveNotification.value("id").toString());
|
||||||
QVariantMap newFirstActiveNotification = this->sendNotification(chatId, firstActiveNotification, activeNotifications);
|
QVariantMap newFirstActiveNotification = this->sendNotification(chatId, firstActiveNotification, activeNotifications);
|
||||||
|
@ -125,45 +126,45 @@ void NotificationManager::handleUpdateNotificationGroup(const QVariantMap notifi
|
||||||
|
|
||||||
void NotificationManager::handleUpdateNotification(const QVariantMap updatedNotification)
|
void NotificationManager::handleUpdateNotification(const QVariantMap updatedNotification)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Received notification update, group ID:" << updatedNotification.value("notification_group_id").toInt();
|
LOG("Received notification update, group ID:" << updatedNotification.value("notification_group_id").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleChatDiscovered(const QString &chatId, const QVariantMap &chatInformation)
|
void NotificationManager::handleChatDiscovered(const QString &chatId, const QVariantMap &chatInformation)
|
||||||
{
|
{
|
||||||
this->chatListMutex.lock();
|
this->chatListMutex.lock();
|
||||||
qDebug() << "[NotificationManager] Adding chat to internal map " << chatId;
|
LOG("Adding chat to internal map" << chatId);
|
||||||
this->chatMap.insert(chatId, chatInformation);
|
this->chatMap.insert(chatId, chatInformation);
|
||||||
this->chatListMutex.unlock();
|
this->chatListMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleNgfConnectionStatus(const bool &connected)
|
void NotificationManager::handleNgfConnectionStatus(const bool &connected)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] NGF Daemon connection status changed " << connected;
|
LOG("NGF Daemon connection status changed" << connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleNgfEventFailed(const quint32 &eventId)
|
void NotificationManager::handleNgfEventFailed(const quint32 &eventId)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] NGF event failed, id: " << eventId;
|
LOG("NGF event failed, id:" << eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleNgfEventCompleted(const quint32 &eventId)
|
void NotificationManager::handleNgfEventCompleted(const quint32 &eventId)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] NGF event completed, id: " << eventId;
|
LOG("NGF event completed, id:" << eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleNgfEventPlaying(const quint32 &eventId)
|
void NotificationManager::handleNgfEventPlaying(const quint32 &eventId)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] NGF event playing, id: " << eventId;
|
LOG("NGF event playing, id:" << eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::handleNgfEventPaused(const quint32 &eventId)
|
void NotificationManager::handleNgfEventPaused(const quint32 &eventId)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] NGF event paused, id: " << eventId;
|
LOG("NGF event paused, id:" << eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap NotificationManager::sendNotification(const QString &chatId, const QVariantMap ¬ificationInformation, const QVariantMap &activeNotifications)
|
QVariantMap NotificationManager::sendNotification(const QString &chatId, const QVariantMap ¬ificationInformation, const QVariantMap &activeNotifications)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Sending notification" << notificationInformation.value("id").toString();
|
LOG("Sending notification" << notificationInformation.value("id").toString());
|
||||||
|
|
||||||
QVariantMap chatInformation = this->chatMap.value(chatId).toMap();
|
QVariantMap chatInformation = this->chatMap.value(chatId).toMap();
|
||||||
QString chatType = chatInformation.value("type").toMap().value("@type").toString();
|
QString chatType = chatInformation.value("type").toMap().value("@type").toString();
|
||||||
|
@ -210,7 +211,7 @@ QVariantMap NotificationManager::sendNotification(const QString &chatId, const Q
|
||||||
|
|
||||||
void NotificationManager::removeNotification(const QVariantMap ¬ificationInformation)
|
void NotificationManager::removeNotification(const QVariantMap ¬ificationInformation)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Removing notification" << notificationInformation.value("id").toString();
|
LOG("Removing notification" << notificationInformation.value("id").toString());
|
||||||
Notification nemoNotification;
|
Notification nemoNotification;
|
||||||
nemoNotification.setReplacesId(notificationInformation.value("replaces_id").toUInt());
|
nemoNotification.setReplacesId(notificationInformation.value("replaces_id").toUInt());
|
||||||
nemoNotification.close();
|
nemoNotification.close();
|
||||||
|
@ -218,14 +219,14 @@ void NotificationManager::removeNotification(const QVariantMap ¬ificationInfo
|
||||||
|
|
||||||
QString NotificationManager::getNotificationText(const QVariantMap ¬ificationContent)
|
QString NotificationManager::getNotificationText(const QVariantMap ¬ificationContent)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Getting notification text from content" << notificationContent;
|
LOG("Getting notification text from content" << notificationContent);
|
||||||
|
|
||||||
return FernschreiberUtils::getMessageShortText(notificationContent, false);
|
return FernschreiberUtils::getMessageShortText(notificationContent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::controlLedNotification(const bool &enabled)
|
void NotificationManager::controlLedNotification(const bool &enabled)
|
||||||
{
|
{
|
||||||
qDebug() << "[NotificationManager] Controlling notification LED" << enabled;
|
LOG("Controlling notification LED" << enabled;
|
||||||
QDBusConnection dbusConnection = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "system");
|
QDBusConnection dbusConnection = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "system");
|
||||||
QDBusInterface dbusInterface("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", dbusConnection);
|
QDBusInterface dbusInterface("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", dbusConnection);
|
||||||
|
|
||||||
|
@ -234,5 +235,4 @@ void NotificationManager::controlLedNotification(const bool &enabled)
|
||||||
} else {
|
} else {
|
||||||
dbusInterface.call("req_led_pattern_deactivate", "PatternCommunicationIM");
|
dbusInterface.call("req_led_pattern_deactivate", "PatternCommunicationIM");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue