diff options
| author | Remko Tronçon <git@el-tramo.be> | 2012-03-09 11:31:47 (GMT) | 
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2012-03-09 11:31:47 (GMT) | 
| commit | 1089374439fa6073800679817198e3c39283113e (patch) | |
| tree | 39c070d8fe65dae6a70f44ccaac9dea5f2957f93 | |
| parent | c83da56f6c93db3dc8040be1137fd40a08bf4132 (diff) | |
| download | swift-contrib-1089374439fa6073800679817198e3c39283113e.zip swift-contrib-1089374439fa6073800679817198e3c39283113e.tar.bz2  | |
Fixed Growl crash.
| -rw-r--r-- | SwifTools/Notifier/GrowlNotifier.mm | 1 | ||||
| -rw-r--r-- | SwifTools/Notifier/GrowlNotifierDelegate.h | 1 | ||||
| -rw-r--r-- | SwifTools/Notifier/GrowlNotifierDelegate.mm | 1 | 
3 files changed, 3 insertions, 0 deletions
diff --git a/SwifTools/Notifier/GrowlNotifier.mm b/SwifTools/Notifier/GrowlNotifier.mm index 31eabd3..b0f26ce 100644 --- a/SwifTools/Notifier/GrowlNotifier.mm +++ b/SwifTools/Notifier/GrowlNotifier.mm @@ -3,70 +3,71 @@   * Licensed under the GNU General Public License v3.   * See Documentation/Licenses/GPLv3.txt for more information.   */  #include <SwifTools/Notifier/GrowlNotifier.h>  #include <boost/smart_ptr/make_shared.hpp>  #include <set>  #include <SwifTools/Notifier/GrowlNotifierDelegate.h>  #include <SwifTools/Cocoa/CocoaUtil.h>  #include <Swiften/Base/foreach.h>  #include <Swiften/Base/ByteArray.h>  #pragma GCC diagnostic ignored "-Wold-style-cast"  namespace {  	struct Context {  		Context(const boost::function<void()>& callback) : callback(new boost::function<void()>(callback)) {}  		boost::function<void()>* callback;  	};  }  namespace Swift {  class GrowlNotifier::Private {  	public:  		std::set<Context*> pendingNotifications;  		boost::intrusive_ptr<GrowlNotifierDelegate> delegate;  };  GrowlNotifier::GrowlNotifier(const std::string& name) {  	p = boost::make_shared<Private>();  	p->delegate = boost::intrusive_ptr<GrowlNotifierDelegate>([[GrowlNotifierDelegate alloc] init], false); +	p->delegate.get().notifier = this;  	p->delegate.get().name = STD2NSSTRING(name);  	NSMutableArray* allNotifications = [[NSMutableArray alloc] init];  	foreach(Type type, getAllTypes()) {  		[allNotifications addObject: STD2NSSTRING(typeToString(type))];  	}  	NSMutableArray* defaultNotifications = [[NSMutableArray alloc] init];  	foreach(Type type, getDefaultTypes()) {  		[defaultNotifications addObject: STD2NSSTRING(typeToString(type))];  	}  	p->delegate.get().registrationDictionary = [[[NSDictionary alloc]   			initWithObjects: [NSArray arrayWithObjects: allNotifications, defaultNotifications, nil]   			forKeys: [NSArray arrayWithObjects: GROWL_NOTIFICATIONS_ALL, GROWL_NOTIFICATIONS_DEFAULT, nil]] autorelease];  	[allNotifications release];  	[defaultNotifications release];  	[GrowlApplicationBridge setGrowlDelegate: p->delegate.get()];  }  GrowlNotifier::~GrowlNotifier() {  	[GrowlApplicationBridge setGrowlDelegate: nil];  	foreach (Context* context, p->pendingNotifications) {  		delete context;  	}  	p->pendingNotifications.clear();  }  void GrowlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picturePath, boost::function<void()> callback) {  	ByteArray picture;  	readByteArrayFromFile(picture, picturePath.string());  	Context* context = new Context(callback); diff --git a/SwifTools/Notifier/GrowlNotifierDelegate.h b/SwifTools/Notifier/GrowlNotifierDelegate.h index 7a556cc..b7f0968 100644 --- a/SwifTools/Notifier/GrowlNotifierDelegate.h +++ b/SwifTools/Notifier/GrowlNotifierDelegate.h @@ -1,28 +1,29 @@  /*   * Copyright (c) 2011 Remko Tronçon   * Licensed under the GNU General Public License v3.   * See Documentation/Licenses/GPLv3.txt for more information.   */  #import <Growl/Growl.h>  namespace Swift {  	class GrowlNotifier;  }  @interface GrowlNotifierDelegate : NSObject<GrowlApplicationBridgeDelegate> {  	Swift::GrowlNotifier* notifier;  	NSString* name;  	NSDictionary* registrationDictionary;  }  @property (nonatomic, retain) NSDictionary* registrationDictionary;  @property (nonatomic, copy) NSString* name; +@property (nonatomic) Swift::GrowlNotifier* notifier;  - (NSDictionary*) registrationDictionaryForGrowl;  - (NSString *) applicationNameForGrowl;  - (void) growlNotificationWasClicked: (id) clickContext;  - (void) growlNotificationTimedOut: (id) clickContext;  @end diff --git a/SwifTools/Notifier/GrowlNotifierDelegate.mm b/SwifTools/Notifier/GrowlNotifierDelegate.mm index c7f725f..6952cab 100644 --- a/SwifTools/Notifier/GrowlNotifierDelegate.mm +++ b/SwifTools/Notifier/GrowlNotifierDelegate.mm @@ -1,34 +1,35 @@  /*   * Copyright (c) 2011 Remko Tronçon   * Licensed under the GNU General Public License v3.   * See Documentation/Licenses/GPLv3.txt for more information.   */  #import "GrowlNotifierDelegate.h"  #include <SwifTools/Notifier/GrowlNotifier.h>  @implementation GrowlNotifierDelegate;  @synthesize registrationDictionary;  @synthesize name; +@synthesize notifier;  using namespace Swift;  - (NSString *) applicationNameForGrowl {  	return name;  }  - (NSDictionary*) registrationDictionaryForGrowl {  	return registrationDictionary;  }  - (void) growlNotificationWasClicked: (id) clickContext {  	notifier->handleNotificationClicked(clickContext);  }  - (void) growlNotificationTimedOut: (id) clickContext {  	notifier->handleNotificationTimedOut(clickContext);  }  @end  | 
 Swift