summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'SwifTools')
-rw-r--r--SwifTools/Notifier/GrowlNotifier.cpp2
-rw-r--r--SwifTools/Notifier/GrowlNotifier.h2
-rw-r--r--SwifTools/Notifier/LoggingNotifier.h2
-rw-r--r--SwifTools/Notifier/Notifier.cpp9
-rw-r--r--SwifTools/Notifier/Notifier.h16
-rw-r--r--SwifTools/Notifier/NullNotifier.h2
-rw-r--r--SwifTools/Notifier/SnarlNotifier.cpp2
-rw-r--r--SwifTools/Notifier/SnarlNotifier.h2
8 files changed, 31 insertions, 6 deletions
diff --git a/SwifTools/Notifier/GrowlNotifier.cpp b/SwifTools/Notifier/GrowlNotifier.cpp
index 3eb580a..066c4d0 100644
--- a/SwifTools/Notifier/GrowlNotifier.cpp
+++ b/SwifTools/Notifier/GrowlNotifier.cpp
@@ -70,7 +70,7 @@ GrowlNotifier::GrowlNotifier(const String& name) {
Growl_SetDelegate(&delegate_);
}
-void GrowlNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picturePath, boost::function<void()> callback) {
+void GrowlNotifier::doShowMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picturePath, boost::function<void()> callback) {
ByteArray picture;
picture.readFromFile(picturePath.string());
diff --git a/SwifTools/Notifier/GrowlNotifier.h b/SwifTools/Notifier/GrowlNotifier.h
index 5d618e6..379181d 100644
--- a/SwifTools/Notifier/GrowlNotifier.h
+++ b/SwifTools/Notifier/GrowlNotifier.h
@@ -24,7 +24,7 @@ namespace Swift {
public:
GrowlNotifier(const String& name);
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+ virtual void doShowMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback);
private:
Growl_Delegate delegate_;
diff --git a/SwifTools/Notifier/LoggingNotifier.h b/SwifTools/Notifier/LoggingNotifier.h
index eea07ef..138d1c5 100644
--- a/SwifTools/Notifier/LoggingNotifier.h
+++ b/SwifTools/Notifier/LoggingNotifier.h
@@ -12,7 +12,7 @@
namespace Swift {
class LoggingNotifier : public Notifier {
public:
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+ virtual void doShowMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
notifications.push_back(Notification(type, subject, description, picture, callback));
}
diff --git a/SwifTools/Notifier/Notifier.cpp b/SwifTools/Notifier/Notifier.cpp
index 7a7ed13..ec6a12f 100644
--- a/SwifTools/Notifier/Notifier.cpp
+++ b/SwifTools/Notifier/Notifier.cpp
@@ -8,9 +8,18 @@
namespace Swift {
+Notifier::Notifier() : enabled(true) {
+}
+
Notifier::~Notifier() {
}
+void Notifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+ if (enabled) {
+ doShowMessage(type, subject, description, picture, callback);
+ }
+}
+
String Notifier::typeToString(Type type) {
switch (type) {
case ContactAvailable: return "Contact Becomes Available";
diff --git a/SwifTools/Notifier/Notifier.h b/SwifTools/Notifier/Notifier.h
index f1a89ef..dab6e90 100644
--- a/SwifTools/Notifier/Notifier.h
+++ b/SwifTools/Notifier/Notifier.h
@@ -14,6 +14,7 @@
namespace Swift {
class Notifier {
public:
+ Notifier();
virtual ~Notifier();
enum Type { ContactAvailable, ContactUnavailable, ContactStatusChange, IncomingMessage, SystemMessage };
@@ -26,11 +27,26 @@ namespace Swift {
const String& subject,
const String& description,
const boost::filesystem::path& picture,
+ boost::function<void()> callback);
+
+ void setEnabled(bool b) {
+ enabled = b;
+ }
+
+ private:
+ virtual void doShowMessage(
+ Type type,
+ const String& subject,
+ const String& description,
+ const boost::filesystem::path& picture,
boost::function<void()> callback) = 0;
protected:
String typeToString(Type type);
static std::vector<Type> getAllTypes();
static std::vector<Type> getDefaultTypes();
+
+ private:
+ bool enabled;
};
}
diff --git a/SwifTools/Notifier/NullNotifier.h b/SwifTools/Notifier/NullNotifier.h
index e97329b..0b0b3df 100644
--- a/SwifTools/Notifier/NullNotifier.h
+++ b/SwifTools/Notifier/NullNotifier.h
@@ -11,7 +11,7 @@
namespace Swift {
class NullNotifier : public Notifier {
public:
- virtual void showMessage(Type, const String&, const String&, const boost::filesystem::path&, boost::function<void()>) {
+ virtual void doShowMessage(Type, const String&, const String&, const boost::filesystem::path&, boost::function<void()>) {
}
};
}
diff --git a/SwifTools/Notifier/SnarlNotifier.cpp b/SwifTools/Notifier/SnarlNotifier.cpp
index 1cd3f9d..9162ff7 100644
--- a/SwifTools/Notifier/SnarlNotifier.cpp
+++ b/SwifTools/Notifier/SnarlNotifier.cpp
@@ -33,7 +33,7 @@ SnarlNotifier::~SnarlNotifier() {
}
}
-void SnarlNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+void SnarlNotifier::doShowMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
int timeout = (type == Type::IncomingMessage || type == Type::SystemMessage) ? MESSAGE_NOTIFICATION_TIMEOUT : STATUS_NOTIFICATION_TIMEOUT;
int notificationID = snarl.ShowMessageEx(typeToString(type).getUTF8Data(), subject.getUTF8Data(), description.getUTF8Data(), timeout, picture.string().c_str(), window->getID(), SWIFT_SNARLNOTIFIER_MESSAGE_ID);
if (notificationID > 0) {
diff --git a/SwifTools/Notifier/SnarlNotifier.h b/SwifTools/Notifier/SnarlNotifier.h
index 2f64166..0fad5c7 100644
--- a/SwifTools/Notifier/SnarlNotifier.h
+++ b/SwifTools/Notifier/SnarlNotifier.h
@@ -19,7 +19,7 @@ namespace Swift {
SnarlNotifier(const String& name, Win32NotifierWindow* window, const boost::filesystem::path& icon);
~SnarlNotifier();
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+ virtual void doShowMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback);
private:
void handleMessageReceived(MSG* message);