summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'SwifTools/Notifier/GrowlNotifier.cpp')
-rw-r--r--SwifTools/Notifier/GrowlNotifier.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/SwifTools/Notifier/GrowlNotifier.cpp b/SwifTools/Notifier/GrowlNotifier.cpp
index 4c671ac..7ea7193 100644
--- a/SwifTools/Notifier/GrowlNotifier.cpp
+++ b/SwifTools/Notifier/GrowlNotifier.cpp
@@ -17,22 +17,30 @@
namespace {
struct Context {
Context() {}
- Context(const boost::function<void()>& callback) : callback(callback) {}
+ Context(const boost::function<void()>& callback) : callback(new boost::function<void()>(callback)) {}
- boost::function<void()> callback;
+ boost::function<void()>* callback;
};
- void notificationClicked(CFPropertyListRef growlContext) {
+ void processNotification(CFPropertyListRef growlContext, bool activateCallback) {
Context context;
CFDataRef growlContextData = (CFDataRef) CFArrayGetValueAtIndex((CFArrayRef) growlContext, 0);
assert(CFDataGetLength(growlContextData) == sizeof(Context));
CFDataGetBytes(growlContextData, CFRangeMake(0, CFDataGetLength(growlContextData)), (UInt8*) &context);
- context.callback();
+ if (activateCallback) {
+ (*context.callback)();
+ }
+ delete context.callback;
+ }
+
+ void notificationClicked(CFPropertyListRef growlContext) {
+ processNotification(growlContext, true);
}
- void notificationTimedout(CFPropertyListRef) {
+ void notificationTimedout(CFPropertyListRef growlContext) {
+ processNotification(growlContext, false);
}
}