2018-05-05 22:40:24 +03:00
|
|
|
#include "notifications/Manager.h"
|
|
|
|
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
#include <QtMac>
|
|
|
|
|
|
|
|
@interface NSUserNotification (CFIPrivate)
|
|
|
|
- (void)set_identityImage:(NSImage *)image;
|
|
|
|
@end
|
|
|
|
|
2018-07-11 17:33:02 +03:00
|
|
|
NotificationsManager::NotificationsManager(QObject *parent): QObject(parent)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-05-05 22:40:24 +03:00
|
|
|
void
|
2018-07-11 17:33:02 +03:00
|
|
|
NotificationsManager::postNotification(
|
|
|
|
const QString &roomId,
|
|
|
|
const QString &eventId,
|
|
|
|
const QString &roomName,
|
|
|
|
const QString &senderName,
|
|
|
|
const QString &text,
|
2021-02-12 19:28:41 +03:00
|
|
|
const QImage &icon,
|
|
|
|
const bool &isEmoteMessage)
|
2018-05-05 22:40:24 +03:00
|
|
|
{
|
2018-07-11 17:33:02 +03:00
|
|
|
Q_UNUSED(roomId);
|
|
|
|
Q_UNUSED(eventId);
|
|
|
|
Q_UNUSED(icon);
|
|
|
|
|
2018-05-05 22:40:24 +03:00
|
|
|
NSUserNotification * notif = [[NSUserNotification alloc] init];
|
|
|
|
|
|
|
|
notif.title = roomName.toNSString();
|
2018-07-11 17:33:02 +03:00
|
|
|
notif.subtitle = QString("%1 sent a message").arg(senderName).toNSString();
|
2021-02-12 19:28:41 +03:00
|
|
|
if (isEmoteMessage)
|
|
|
|
notif.informativeText = QString("* ").append(senderName).append(" ").append(text).toNSString();
|
|
|
|
else
|
|
|
|
notif.informativeText = text.toNSString();
|
2018-05-05 22:40:24 +03:00
|
|
|
notif.soundName = NSUserNotificationDefaultSoundName;
|
|
|
|
|
|
|
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notif];
|
|
|
|
[notif autorelease];
|
|
|
|
}
|
2018-07-11 17:33:02 +03:00
|
|
|
|
|
|
|
//unused
|
|
|
|
void
|
|
|
|
NotificationsManager::actionInvoked(uint, QString)
|
2021-01-07 13:21:10 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NotificationsManager::notificationReplied(uint, QString)
|
2018-07-11 17:33:02 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NotificationsManager::notificationClosed(uint, uint)
|
|
|
|
{
|
|
|
|
}
|
2020-04-09 21:52:50 +03:00
|
|
|
|
|
|
|
void
|
2020-04-13 18:01:57 +03:00
|
|
|
NotificationsManager::removeNotification(const QString &, const QString &)
|
2020-04-09 21:52:50 +03:00
|
|
|
{}
|
|
|
|
|