summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-12-24 10:08:47 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-12-24 11:00:04 (GMT)
commit3e2a3a4cdb0b6bc0cf79423c48400c544830177a (patch)
treedcc53224fd0b0ed0bd704a4b097f5c425dbd672e
parentf69d027b7e3b4260e514a77f7195ec511977b63e (diff)
downloadswift-3e2a3a4cdb0b6bc0cf79423c48400c544830177a.zip
swift-3e2a3a4cdb0b6bc0cf79423c48400c544830177a.tar.bz2
Enable "Show notifications" toggle when Growl isn't installed.
-rw-r--r--SwifTools/Notifier/GrowlNotifier.h1
-rw-r--r--SwifTools/Notifier/GrowlNotifier.mm12
-rw-r--r--SwifTools/Notifier/Notifier.h4
-rw-r--r--SwifTools/Notifier/TogglableNotifier.h6
-rw-r--r--Swift/Controllers/MainController.cpp1
-rw-r--r--Swift/Controllers/UIInterfaces/LoginWindow.h1
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp12
-rw-r--r--Swift/QtUI/QtLoginWindow.h1
8 files changed, 31 insertions, 7 deletions
diff --git a/SwifTools/Notifier/GrowlNotifier.h b/SwifTools/Notifier/GrowlNotifier.h
index ffd717a..cb0d089 100644
--- a/SwifTools/Notifier/GrowlNotifier.h
+++ b/SwifTools/Notifier/GrowlNotifier.h
@@ -22,6 +22,7 @@ namespace Swift {
GrowlNotifier(const std::string& name);
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);
diff --git a/SwifTools/Notifier/GrowlNotifier.mm b/SwifTools/Notifier/GrowlNotifier.mm
index 108259a..cb4790e 100644
--- a/SwifTools/Notifier/GrowlNotifier.mm
+++ b/SwifTools/Notifier/GrowlNotifier.mm
@@ -48,6 +48,9 @@ GrowlNotifier::GrowlNotifier(const std::string& name) {
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()];
}
@@ -56,8 +59,7 @@ void GrowlNotifier::showMessage(Type type, const std::string& subject, const std
ByteArray picture;
readByteArrayFromFile(picture, picturePath.string());
- Context* contextPtr = new Context(callback);
- NSData* context = [NSData dataWithBytes: &contextPtr length: sizeof(contextPtr)];
+ Context* context = new Context(callback);
[GrowlApplicationBridge
notifyWithTitle: STD2NSSTRING(subject)
@@ -66,7 +68,7 @@ void GrowlNotifier::showMessage(Type type, const std::string& subject, const std
iconData: [NSData dataWithBytes: vecptr(picture) length: picture.size()]
priority: 0
isSticky: NO
- clickContext: context];
+ clickContext: [NSData dataWithBytes: &context length: sizeof(context)]];
}
void GrowlNotifier::handleNotificationClicked(void* rawData) {
@@ -81,4 +83,8 @@ void GrowlNotifier::handleNotificationTimedOut(void* rawData) {
delete *(Context**) [((NSData*) rawData) bytes];
}
+bool GrowlNotifier::isExternallyConfigured() const {
+ return ![GrowlApplicationBridge isMistEnabled];
+}
+
}
diff --git a/SwifTools/Notifier/Notifier.h b/SwifTools/Notifier/Notifier.h
index d6bd878..1bcd58d 100644
--- a/SwifTools/Notifier/Notifier.h
+++ b/SwifTools/Notifier/Notifier.h
@@ -32,6 +32,10 @@ namespace Swift {
return true;
}
+ virtual bool isExternallyConfigured() const {
+ return false;
+ }
+
protected:
std::string typeToString(Type type);
static std::vector<Type> getAllTypes();
diff --git a/SwifTools/Notifier/TogglableNotifier.h b/SwifTools/Notifier/TogglableNotifier.h
index e8de5de..7abfd42 100644
--- a/SwifTools/Notifier/TogglableNotifier.h
+++ b/SwifTools/Notifier/TogglableNotifier.h
@@ -41,11 +41,15 @@ namespace Swift {
}
virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
- if (getCurrentlyEnabled()) {
+ if (getCurrentlyEnabled() || notifier->isExternallyConfigured()) {
notifier->showMessage(type, subject, description, picture, callback);
}
}
+ virtual bool isExternallyConfigured() const {
+ return notifier->isExternallyConfigured();
+ }
+
private:
Notifier* notifier;
bool persistentEnabled;
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 7ed53a2..046120d 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -136,6 +136,7 @@ MainController::MainController(
systemTrayController_ = new SystemTrayController(eventController_, systemTray);
loginWindow_ = uiFactory_->createLoginWindow(uiEventStream_);
+ loginWindow_->setShowNotificationToggle(!notifier->isExternallyConfigured());
soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings, uiEventStream_);
xmppURIController_ = new XMPPURIController(uriHandler_, uiEventStream_);
diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h
index 61fcaa1..a8ee5a4 100644
--- a/Swift/Controllers/UIInterfaces/LoginWindow.h
+++ b/Swift/Controllers/UIInterfaces/LoginWindow.h
@@ -20,6 +20,7 @@ namespace Swift {
virtual void selectUser(const std::string&) = 0;
virtual void morphInto(MainWindow *mainWindow) = 0;
virtual void loggedOut() = 0;
+ virtual void setShowNotificationToggle(bool) = 0;
virtual void setMessage(const std::string&) = 0;
virtual void setIsLoggingIn(bool loggingIn) = 0;
virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate) = 0;
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index 5a8b9ab..43abd91 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -185,9 +185,6 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream, bool eagleMode) : QMa
toggleNotificationsAction_->setCheckable(true);
toggleNotificationsAction_->setChecked(true);
connect(toggleNotificationsAction_, SIGNAL(toggled(bool)), SLOT(handleToggleNotifications(bool)));
-#if defined(SWIFTEN_PLATFORM_LINUX) || defined(SWIFTEN_PLATFORM_WINDOWS)
- generalMenu_->addAction(toggleNotificationsAction_);
-#endif
#ifndef SWIFTEN_PLATFORM_MACOSX
swiftMenu_->addSeparator();
@@ -216,6 +213,15 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream, bool eagleMode) : QMa
this->show();
}
+void QtLoginWindow::setShowNotificationToggle(bool toggle) {
+ if (toggle) {
+ generalMenu_->addAction(toggleNotificationsAction_);
+ }
+ else {
+ generalMenu_->removeAction(toggleNotificationsAction_);
+ }
+}
+
bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) {
if (obj == username_->view() && event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index a830af5..df133b1 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -38,6 +38,7 @@ namespace Swift {
void morphInto(MainWindow *mainWindow);
virtual void loggedOut();
+ virtual void setShowNotificationToggle(bool);
virtual void setMessage(const std::string& message);
virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate);
virtual void removeAvailableAccount(const std::string& jid);