FIRE-6339: Add Growl support on OS X. Adapted from a patch by Nagi Michinaga.

Tonya Souther 2012-05-25 22:47:18 -05:00
parent f7e15c53c9
commit 28e7158b99
8 changed files with 72 additions and 30 deletions

View File

@ -20,9 +20,9 @@
<key>archive</key>
<map>
<key>hash</key>
<string>f075e96d8e1bfdd1f518829f0d7b74af</string>
<string>4ece2c0c7376aa004e2d54b1b28cc22a</string>
<key>url</key>
<uri>http://downloads.phoenixviewer.com/growl-1.2.1-darwin.tar.gz</uri>
<uri>http://phoenixviewer.com/app/packages/growl-1.3-darwin-20120525.tar.bz2</uri>
</map>
</map>
<key>windows</key>

View File

@ -12,11 +12,11 @@ if (STANDALONE)
#set(GROWL_INCLUDE_DIRS ${LIBNOTIFY_INCLUDE_DIR})
#set(GROWL_LIBRARY ${LIBNOTIFY_LIBRARIES})
else (STANDALONE)
#include(Prebuilt)
#use_prebuilt_binary(Growl)
if (DARWIN)
#set(GROWL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/Growl)
#set(GROWL_LIBRARY growl)
include(Prebuilt)
use_prebuilt_binary(Growl)
set(GROWL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/Growl)
add_definitions( -DHAS_GROWL)
elseif (WINDOWS)
include(Prebuilt)
use_prebuilt_binary(Growl)

View File

@ -1308,11 +1308,18 @@ list(APPEND viewer_HEADER_FILES ${CMAKE_CURRENT_BINARY_DIR}/kvflickrkeys.h)
source_group("CMake Rules" FILES ViewerInstall.cmake)
if (DARWIN)
LIST(APPEND viewer_SOURCE_FILES llappviewermacosx.cpp)
#LIST(APPEND viewer_HEADER_FILES growlnotifiermacosx-objc.h)
#LIST(APPEND viewer_SOURCE_FILES growlnotifiermacosx-objc.mm)
#LIST(APPEND viewer_SOURCE_FILES growlnotifiermacosx.h)
#LIST(APPEND viewer_SOURCE_FILES growlnotifiermacosx.cpp)
LIST(APPEND viewer_SOURCE_FILES
llappviewermacosx.cpp
growlmanager.cpp
growlnotifiermacosx.cpp
growlnotifiermacosx-objc.mm
)
LIST(APPEND viewer_HEADER_FILES
growlmanager.h
growlnotifiermacosx.h
growlnotifiermacosx-objc.h
)
find_library(AGL_LIBRARY AGL)

View File

@ -49,7 +49,7 @@
// Platform-specific includes
#ifdef LL_DARWIN
//#include "growlnotifiermacosx.h"
#include "growlnotifiermacosx.h"
#elif LL_WINDOWS
#include "growlnotifierwin.h"
#elif LL_LINUX
@ -63,8 +63,8 @@ GrowlManager::GrowlManager() : LLEventTimer(GROWL_THROTTLE_CLEANUP_PERIOD)
{
// Create a notifier appropriate to the platform.
#ifdef LL_DARWIN
//this->mNotifier = new GrowlNotifierMacOSX();
//LL_INFOS("GrowlManagerInit") << "Created GrowlNotifierMacOSX." << LL_ENDL;
this->mNotifier = new GrowlNotifierMacOSX();
LL_INFOS("GrowlManagerInit") << "Created GrowlNotifierMacOSX." << LL_ENDL;
#elif LL_WINDOWS
this->mNotifier = new GrowlNotifierWin();
LL_INFOS("GrowlManagerInit") << "Created GrowlNotifierWin." << LL_ENDL;

View File

@ -31,52 +31,88 @@
#import <Cocoa/Cocoa.h>
#import "Growl/Growl.h"
// Make a happy delegate (that does nothing)
// Make a happy delegate (that does nothing other than the required response to a registration dictionary)
@interface FirestormBridge : NSObject <GrowlApplicationBridgeDelegate>
@end
@implementation FirestormBridge
- (NSDictionary *) registrationDictionaryForGrowl {
NSDictionary *regDict = [NSDictionary dictionaryWithObjectsAndKeys:
@"Firestorm Viewer", GROWL_APP_NAME,
nil];
return regDict;
}
@end
bool isInstalled = false;
void growlApplicationBridgeNotify(const std::string& withTitle, const std::string& description, const std::string& notificationName,
void *iconData, unsigned int iconDataSize, int priority, bool isSticky) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[GrowlApplicationBridge notifyWithTitle:[NSString stringWithCString:withTitle.c_str() encoding:NSUTF8StringEncoding]
Class GAB = NSClassFromString(@"GrowlApplicationBridge");
if([GAB respondsToSelector:@selector(notifyWithTitle:description:notificationName:iconData:priority:isSticky:clickContext:identifier:)]) {
[GAB notifyWithTitle:[NSString stringWithCString:withTitle.c_str() encoding:NSUTF8StringEncoding]
description:[NSString stringWithCString:description.c_str() encoding:NSUTF8StringEncoding]
notificationName:[NSString stringWithCString:notificationName.c_str() encoding:NSUTF8StringEncoding]
iconData:(iconData == NULL ? nil : [NSData dataWithBytes:iconData length:iconDataSize])
priority:priority
isSticky:isSticky
clickContext:nil
];
clickContext:nil];
//NSLog(@"Growl msg: %@:%@", [NSString stringWithCString:withTitle.c_str() encoding:NSUTF8StringEncoding], [NSString stringWithCString:description.c_str() encoding:NSUTF8StringEncoding]);
}
[pool release];
}
void growlApplicationBridgeInit() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
FirestormBridge *delegate = [[[FirestormBridge alloc] init] autorelease];
[GrowlApplicationBridge setGrowlDelegate:delegate];
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *path = [[mainBundle privateFrameworksPath] stringByAppendingPathComponent:@"Growl"];
if(NSAppKitVersionNumber >= 1038)
path = [path stringByAppendingPathComponent:@"1.3"];
else
path = [path stringByAppendingPathComponent:@"1.2.3"];
path = [path stringByAppendingPathComponent:@"Growl.framework"];
//NSLog(@"path: %@", path);
NSBundle *growlFramework = [NSBundle bundleWithPath:path];
if([growlFramework load])
{
NSDictionary *infoDictionary = [growlFramework infoDictionary];
NSLog(@"Using Growl.framework %@ (%@)",
[infoDictionary objectForKey:@"CFBundleShortVersionString"],
[infoDictionary objectForKey:(NSString *)kCFBundleVersionKey]);
FirestormBridge *delegate = [[[FirestormBridge alloc] init] autorelease];
Class GAB = NSClassFromString(@"GrowlApplicationBridge");
if([GAB respondsToSelector:@selector(setGrowlDelegate:)])
[GAB performSelector:@selector(setGrowlDelegate:) withObject:delegate];
isInstalled = true;
}
[pool release];
}
bool growlApplicationBridgeIsGrowlInstalled() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
bool installed = [GrowlApplicationBridge isGrowlInstalled];
[pool release];
return installed;
return isInstalled;
}
void growlApplicationBridgeRegister(const std::string& appname, const std::set<std::string>& notifications)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Class GAB = NSClassFromString(@"GrowlApplicationBridge");
NSMutableArray *notificationArray = [[[NSMutableArray alloc] init] autorelease];
for(std::set<std::string>::iterator itr = notifications.begin(); itr != notifications.end(); ++itr) {
[notificationArray addObject:[NSString stringWithCString:itr->c_str() encoding:NSUTF8StringEncoding]];
}
[GrowlApplicationBridge registerWithDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
[GAB registerWithDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithCString:appname.c_str() encoding:NSUTF8StringEncoding], GROWL_APP_NAME,
notificationArray, GROWL_NOTIFICATIONS_ALL,
notificationArray, GROWL_NOTIFICATIONS_DEFAULT,
nil]];
[pool release];
}
}

View File

@ -33,7 +33,6 @@
GrowlNotifierMacOSX::GrowlNotifierMacOSX()
{
// Work around a Growl 1.1 bug whereby the app bridge *requires* a delegate.
growlApplicationBridgeInit();
LL_INFOS("GrowlNotifierOSX") << "OS X growl notifications initialised." << LL_ENDL;
}

View File

@ -260,7 +260,7 @@ Additional code generously contributed to Firestorm by:
top_pad="10"
width="435"
word_wrap="true">
Satomi Ahn, Katharine Berry, Alexie Birman, nhede Core, Lance Corrimal, Fractured Crystal, NiranV Dean, Sunset Faulkes, Whirly Fizzle, Holy Gavenkrantz, Dawa Gurbux, Albatroz Hird, Vaalith Jinn, Zwagoth Klaar, Kool Koolhoven, Shyotl Kuhr, Nogardrevlis Lectar, Melancholy Lemon, Miguael Liamano, Sione Lomu, Peyton Menges, Kittin Ninetails, Mimika Oh, Andromeda Rage, f0rbidden, programmtest, Mysty Saunders, Thickbrick Sleaford, Hitomi Tiponi, Qwerty Venom, Shin Wasp, Armin Weatherwax, Chalice Yao, Damian Zhaoying and others.
Satomi Ahn, Katharine Berry, Alexie Birman, nhede Core, Lance Corrimal, Fractured Crystal, NiranV Dean, Sunset Faulkes, Whirly Fizzle, Holy Gavenkrantz, Dawa Gurbux, Albatroz Hird, Vaalith Jinn, Zwagoth Klaar, Kool Koolhoven, Shyotl Kuhr, Nogardrevlis Lectar, Melancholy Lemon, Miguael Liamano, Sione Lomu, Peyton Menges, Nagi Michinaga, Kittin Ninetails, Mimika Oh, Andromeda Rage, f0rbidden, programmtest, Mysty Saunders, Thickbrick Sleaford, Hitomi Tiponi, Qwerty Venom, Shin Wasp, Armin Weatherwax, Chalice Yao, Damian Zhaoying and others.
</text_editor>
<text

View File

@ -740,8 +740,8 @@ class DarwinManifest(ViewerManifest):
self.path("../packages/lib/release/libhunspell-1.3.0.dylib", dst="Resources/libhunspell-1.3.0.dylib")
self.path("../viewer_components/updater/scripts/darwin/update_install", "MacOS/update_install")
# Growl library
#self.path("../../libraries/universal-darwin/lib_release/libgrowl.dylib", "Frameworks/Growl.framework/Versions/A/Growl"); # LO - uncomment for work on growl on mac
# Growl Frameworks
self.path("../packages/Frameworks/Growl", dst="Frameworks/Growl")
# most everything goes in the Resources directory
if self.prefix(src="", dst="Resources"):