8 #import <objc/runtime.h> 9 #include <Cocoa/Cocoa.h> 13 - (NSString *)__bundleIdentifier
15 if (
self == [NSBundle mainBundle]) {
16 return @"org.fabcoinfoundation.Fabcoin-Qt";
18 return [
self __bundleIdentifier];
26 if(this->hasUserNotificationCenterSupport()) {
28 QByteArray utf8 = title.toUtf8();
29 char* cString = (
char *)utf8.constData();
30 NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];
33 cString = (
char *)utf8.constData();
34 NSString *textMac = [[NSString alloc] initWithUTF8String:cString];
37 id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
38 [userNotification performSelector:@selector(setTitle:) withObject:titleMac];
39 [userNotification performSelector:@selector(setInformativeText:) withObject:textMac];
41 id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
42 [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];
46 [userNotification release];
53 QByteArray utf8 = script.toUtf8();
54 char* cString = (
char *)utf8.constData();
55 NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString];
57 NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple];
58 NSDictionary *err = nil;
59 [as executeAndReturnError:&err];
61 [scriptApple release];
66 Class possibleClass = NSClassFromString(
@"NSUserNotificationCenter");
69 if(possibleClass!=nil) {
82 Class aPossibleClass = objc_getClass(
"NSBundle");
86 method_exchangeImplementations(class_getInstanceMethod(aPossibleClass,
@selector(bundleIdentifier)),
87 class_getInstanceMethod(aPossibleClass,
@selector(__bundleIdentifier)));
bool hasUserNotificationCenterSupport(void)
check if OS can handle UserNotifications
static MacNotificationHandler * instance()
void sendAppleScript(const QString &script)
executes AppleScript
void showNotification(const QString &title, const QString &text)
shows a 10.8+ UserNotification in the UserNotificationCenter
Macintosh-specific notification handler (supports UserNotificationCenter and Growl).