changeset 2894:eb231c32e0c2 draft

Proper support for Growl 1.3 notifications
author p2k <patrick.p2k.schneider@gmail.com>
date Mon, 12 Mar 2012 14:20:55 +0100
parents 39871d44177a
children 4326939da6ed b790b3ffda99
files src/qt/notificator.cpp src/qt/notificator.h
diffstat 2 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/qt/notificator.cpp
+++ b/src/qt/notificator.cpp
@@ -52,10 +52,13 @@
     OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
     if (status != kLSApplicationNotFoundErr) {
         CFBundleRef bundle = CFBundleCreate(0, cfurl);
+        if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
+            if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
+                mode = Growl13;
+            else
+                mode = Growl12;
+        }
         CFRelease(cfurl);
-        if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
-            mode = Growl;
-        }
         CFRelease(bundle);
     }
 #endif
@@ -226,7 +229,7 @@
 void Notificator::notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon)
 {
     const QString script(
-        "tell application \"GrowlHelperApp\"\n"
+        "tell application \"%5\"\n"
         "  set the allNotificationsList to {\"Notification\"}\n" // -- Make a list of all the notification types (all)
         "  set the enabledNotificationsList to {\"Notification\"}\n" // -- Make a list of the notifications (enabled)
         "  register as application \"%1\" all notifications allNotificationsList default notifications enabledNotificationsList\n" // -- Register our script with Growl
@@ -265,7 +268,8 @@
     QString quotedTitle(title), quotedText(text);
     quotedTitle.replace("\\", "\\\\").replace("\"", "\\");
     quotedText.replace("\\", "\\\\").replace("\"", "\\");
-    qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon), 0);
+    QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp");
+    qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp), 0);
 }
 #endif
 
@@ -282,7 +286,8 @@
         notifySystray(cls, title, text, icon, millisTimeout);
         break;
 #ifdef Q_WS_MAC
-    case Growl:
+    case Growl12:
+    case Growl13:
         notifyGrowl(cls, title, text, icon);
         break;
 #endif
--- a/src/qt/notificator.h
+++ b/src/qt/notificator.h
@@ -48,7 +48,8 @@
         None,
         Freedesktop, // Use DBus org.freedesktop.Notifications
         QSystemTray, // Use QSystemTray::showMessage
-        Growl // Use the Growl notification system (Mac only)
+        Growl12, // Use the Growl 1.2 notification system (Mac only)
+        Growl13 // Use the Growl 1.3 notification system (Mac only)
     };
     QString programName;
     Mode mode;