summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SwifTools/Notifier/GrowlNotifier.h8
-rw-r--r--SwifTools/Notifier/GrowlNotifier.mm16
2 files changed, 17 insertions, 7 deletions
diff --git a/SwifTools/Notifier/GrowlNotifier.h b/SwifTools/Notifier/GrowlNotifier.h
index f1fb8c6..73f1008 100644
--- a/SwifTools/Notifier/GrowlNotifier.h
+++ b/SwifTools/Notifier/GrowlNotifier.h
@@ -23,17 +23,19 @@ namespace Swift {
~GrowlNotifier();
virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
virtual bool isExternallyConfigured() const;
// Called by the delegate. Don't call.
void handleNotificationClicked(void* data);
void handleNotificationTimedOut(void* data);
- virtual void purgeCallbacks() {
-#warning FIXME: Implement
- }
+ virtual void purgeCallbacks();
+
+ private:
+ void clearPendingNotifications();
+
private:
class Private;
boost::shared_ptr<Private> p;
};
}
diff --git a/SwifTools/Notifier/GrowlNotifier.mm b/SwifTools/Notifier/GrowlNotifier.mm
index b0f26ce..c1996d9 100644
--- a/SwifTools/Notifier/GrowlNotifier.mm
+++ b/SwifTools/Notifier/GrowlNotifier.mm
@@ -54,22 +54,19 @@ GrowlNotifier::GrowlNotifier(const std::string& name) {
[allNotifications release];
[defaultNotifications release];
[GrowlApplicationBridge setGrowlDelegate: p->delegate.get()];
}
GrowlNotifier::~GrowlNotifier() {
[GrowlApplicationBridge setGrowlDelegate: nil];
- foreach (Context* context, p->pendingNotifications) {
- delete context;
- }
- p->pendingNotifications.clear();
+ clearPendingNotifications();
}
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);
// Growl sometimes sends timeout notifications twice for the same message. We therefore need
// to keep track of which ones have already been processed.
@@ -100,10 +97,21 @@ void GrowlNotifier::handleNotificationTimedOut(void* rawData) {
if (p->pendingNotifications.erase(context) > 0) {
delete context;
}
}
bool GrowlNotifier::isExternallyConfigured() const {
return ![GrowlApplicationBridge isMistEnabled];
}
+void GrowlNotifier::purgeCallbacks() {
+ clearPendingNotifications();
+}
+
+void GrowlNotifier::clearPendingNotifications() {
+ foreach (Context* context, p->pendingNotifications) {
+ delete context;
+ }
+ p->pendingNotifications.clear();
+}
+
}