From 9f708080c81220e15e61de0bed62319ac356f744 Mon Sep 17 00:00:00 2001 From: "Sebastian J. Wolf" Date: Wed, 2 Sep 2020 23:05:09 +0200 Subject: [PATCH] We need chat information in notification manager --- src/notificationmanager.cpp | 9 +++++++++ src/notificationmanager.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/notificationmanager.cpp b/src/notificationmanager.cpp index a79139a..bb8fa2f 100644 --- a/src/notificationmanager.cpp +++ b/src/notificationmanager.cpp @@ -27,6 +27,7 @@ NotificationManager::NotificationManager(TDLibWrapper *tdLibWrapper, QObject *pa connect(this->tdLibWrapper, SIGNAL(activeNotificationsUpdated(QVariantList)), this, SLOT(handleUpdateActiveNotifications(QVariantList))); connect(this->tdLibWrapper, SIGNAL(notificationGroupUpdated(QVariantMap)), this, SLOT(handleUpdateNotificationGroup(QVariantMap))); connect(this->tdLibWrapper, SIGNAL(notificationUpdated(QVariantMap)), this, SLOT(handleUpdateNotification(QVariantMap))); + connect(this->tdLibWrapper, SIGNAL(newChatDiscovered(QString, QVariantMap)), this, SLOT(handleChatDiscovered(QString, QVariantMap))); } NotificationManager::~NotificationManager() @@ -48,3 +49,11 @@ void NotificationManager::handleUpdateNotification(const QVariantMap updatedNoti { qDebug() << "[NotificationManager] Received notification update, group ID:" << updatedNotification.value("notification_group_id").toInt(); } + +void NotificationManager::handleChatDiscovered(const QString &chatId, const QVariantMap &chatInformation) +{ + this->chatListMutex.lock(); + qDebug() << "[NotificationManager] Adding chat to internal map " << chatId; + this->chatMap.insert(chatId, chatInformation); + this->chatListMutex.unlock(); +} diff --git a/src/notificationmanager.h b/src/notificationmanager.h index df8c0a1..c28d0c7 100644 --- a/src/notificationmanager.h +++ b/src/notificationmanager.h @@ -21,6 +21,7 @@ #define NOTIFICATIONMANAGER_H #include +#include #include "tdlibwrapper.h" @@ -38,10 +39,13 @@ public slots: void handleUpdateActiveNotifications(const QVariantList notificationGroups); void handleUpdateNotificationGroup(const QVariantMap notificationGroupUpdate); void handleUpdateNotification(const QVariantMap updatedNotification); + void handleChatDiscovered(const QString &chatId, const QVariantMap &chatInformation); private: TDLibWrapper *tdLibWrapper; + QVariantMap chatMap; + QMutex chatListMutex; };