|
|
@ -5,8 +5,21 @@ |
|
|
|
#include "macnotificationhandler.h" |
|
|
|
#include "macnotificationhandler.h" |
|
|
|
|
|
|
|
|
|
|
|
#undef slots |
|
|
|
#undef slots |
|
|
|
|
|
|
|
#import <objc/runtime.h> |
|
|
|
#include <Cocoa/Cocoa.h> |
|
|
|
#include <Cocoa/Cocoa.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add an obj-c category (extension) to return the expected bundle identifier |
|
|
|
|
|
|
|
@implementation NSBundle(returnCorrectIdentifier) |
|
|
|
|
|
|
|
- (NSString *)__bundleIdentifier |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (self == [NSBundle mainBundle]) { |
|
|
|
|
|
|
|
return @"org.bitcoinfoundation.Bitcoin-Qt"; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return [self __bundleIdentifier]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@end |
|
|
|
|
|
|
|
|
|
|
|
void MacNotificationHandler::showNotification(const QString &title, const QString &text) |
|
|
|
void MacNotificationHandler::showNotification(const QString &title, const QString &text) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// check if users OS has support for NSUserNotification |
|
|
|
// check if users OS has support for NSUserNotification |
|
|
@ -63,7 +76,16 @@ bool MacNotificationHandler::hasUserNotificationCenterSupport(void) |
|
|
|
MacNotificationHandler *MacNotificationHandler::instance() |
|
|
|
MacNotificationHandler *MacNotificationHandler::instance() |
|
|
|
{ |
|
|
|
{ |
|
|
|
static MacNotificationHandler *s_instance = NULL; |
|
|
|
static MacNotificationHandler *s_instance = NULL; |
|
|
|
if (!s_instance) |
|
|
|
if (!s_instance) { |
|
|
|
s_instance = new MacNotificationHandler(); |
|
|
|
s_instance = new MacNotificationHandler(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class aPossibleClass = objc_getClass("NSBundle"); |
|
|
|
|
|
|
|
if (aPossibleClass) { |
|
|
|
|
|
|
|
// change NSBundle -bundleIdentifier method to return a correct bundle identifier |
|
|
|
|
|
|
|
// a bundle identifier is required to use OSXs User Notification Center |
|
|
|
|
|
|
|
method_exchangeImplementations(class_getInstanceMethod(aPossibleClass, @selector(bundleIdentifier)), |
|
|
|
|
|
|
|
class_getInstanceMethod(aPossibleClass, @selector(__bundleIdentifier))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return s_instance; |
|
|
|
return s_instance; |
|
|
|
} |
|
|
|
} |
|
|
|