mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-20 21:02:02 +03:00
4ad190a558
This gives more insight about the logs and allow setting fine-tuned logging rules. The categories are set to only output Info by default so this allows us to provide more concise logging while keeping the ability to extract more information for a specific category when developping or debugging customer issues. Issue #5647
44 lines
1.3 KiB
Text
44 lines
1.3 KiB
Text
#include <QString>
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
@interface NotificationCenterDelegate : NSObject
|
|
@end
|
|
@implementation NotificationCenterDelegate
|
|
// Always show, even if app is active at the moment.
|
|
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
|
|
shouldPresentNotification:(NSUserNotification *)notification
|
|
{
|
|
Q_UNUSED(center);
|
|
Q_UNUSED(notification);
|
|
return YES;
|
|
}
|
|
@end
|
|
|
|
namespace OCC {
|
|
|
|
bool canOsXSendUserNotification()
|
|
{
|
|
return NSClassFromString(@"NSUserNotificationCenter") != nil;
|
|
}
|
|
|
|
void sendOsXUserNotification(const QString &title, const QString &message)
|
|
{
|
|
Class cuserNotificationCenter = NSClassFromString(@"NSUserNotificationCenter");
|
|
id userNotificationCenter = [cuserNotificationCenter defaultUserNotificationCenter];
|
|
|
|
static dispatch_once_t once;
|
|
dispatch_once(&once, ^{
|
|
id delegate = [[NotificationCenterDelegate alloc] init];
|
|
[userNotificationCenter setDelegate:delegate];
|
|
});
|
|
|
|
Class cuserNotification = NSClassFromString(@"NSUserNotification");
|
|
id notification = [[cuserNotification alloc] init];
|
|
[notification setTitle:[NSString stringWithUTF8String:title.toUtf8().data()]];
|
|
[notification setInformativeText:[NSString stringWithUTF8String:message.toUtf8().data()]];
|
|
|
|
[userNotificationCenter deliverNotification:notification];
|
|
[notification release];
|
|
}
|
|
|
|
}
|