blob: 5609d3dea7588001c25590f30c17e56c57700609 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#include "notifications/Manager.h"
#include <Foundation/Foundation.h>
#include <QtMac>
#include "Cache.h"
#include "EventAccessors.h"
#include "MatrixClient.h"
#include "Utils.h"
#include <mtx/responses/notifications.hpp>
@interface NSUserNotification (CFIPrivate)
- (void)set_identityImage:(NSImage *)image;
@end
NotificationsManager::NotificationsManager(QObject *parent): QObject(parent)
{
}
void
NotificationsManager::postNotification(const mtx::responses::Notification ¬ification,
const QImage &icon)
{
Q_UNUSED(icon);
const auto sender = cache::displayName(QString::fromStdString(notification.room_id), QString::fromStdString(mtx::accessors::sender(notification.event)));
const auto text = utils::event_body(notification.event);
NSUserNotification * notif = [[NSUserNotification alloc] init];
notif.title = QString::fromStdString(cache::singleRoomInfo(notification.room_id).name).toNSString();
notif.subtitle = QString("%1 sent a message").arg(sender).toNSString();
if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote)
notif.informativeText = QString("* ").append(sender).append(" ").append(text).toNSString();
else
notif.informativeText = text.toNSString();
notif.soundName = NSUserNotificationDefaultSoundName;
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notif];
[notif autorelease];
}
//unused
void
NotificationsManager::actionInvoked(uint, QString)
{
}
void
NotificationsManager::notificationReplied(uint, QString)
{
}
void
NotificationsManager::notificationClosed(uint, uint)
{
}
void
NotificationsManager::removeNotification(const QString &, const QString &)
{}
|