From 4804022049cb53ac28902639274826b68a803c18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sat, 30 Oct 2010 21:55:41 +0200
Subject: When MUC notifications are clicked, open the MUC.

Release-Notes: When clicking notifications coming from rooms, bring up the room dialog.
Resolves: #674

diff --git a/Swift/Controllers/EventNotifier.cpp b/Swift/Controllers/EventNotifier.cpp
index e08c8ed..343abd9 100644
--- a/Swift/Controllers/EventNotifier.cpp
+++ b/Swift/Controllers/EventNotifier.cpp
@@ -33,7 +33,11 @@ void EventNotifier::handleEventAdded(boost::shared_ptr<StanzaEvent> event) {
 		JID jid = messageEvent->getStanza()->getFrom();
 		String title = nickResolver->jidToNick(jid);
 		if (!messageEvent->getStanza()->isError() && !messageEvent->getStanza()->getBody().isEmpty()) {
-			notifier->showMessage(Notifier::IncomingMessage, title, messageEvent->getStanza()->getBody(), avatarManager->getAvatarPath(jid), boost::bind(&EventNotifier::handleNotificationActivated, this, jid));
+			JID activationJID = jid;
+			if (messageEvent->getStanza()->getType() == Message::Groupchat) {
+				activationJID = jid.toBare();
+			}
+			notifier->showMessage(Notifier::IncomingMessage, title, messageEvent->getStanza()->getBody(), avatarManager->getAvatarPath(jid), boost::bind(&EventNotifier::handleNotificationActivated, this, activationJID));
 		}
 	}
 	else if(boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event)) {
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 92a3f2a..4501f2c 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -56,6 +56,7 @@
 #include "Swiften/StringCodecs/Hexify.h"
 #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h"
 #include "Swift/Controllers/UIEvents/ToggleNotificationsUIEvent.h"
+#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h"
 
 namespace Swift {
 
@@ -509,7 +510,14 @@ void MainController::handleVCardReceived(const JID& jid, VCard::ref vCard) {
 
 void MainController::handleNotificationClicked(const JID& jid) {
 	assert(chatsManager_);
-	uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(jid)));
+	if (client_) {
+		if (client_->getMUCRegistry()->isMUC(jid)) {
+			uiEventStream_->send(boost::shared_ptr<JoinMUCUIEvent>(new JoinMUCUIEvent(jid)));
+		}
+		else {
+			uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(jid)));
+		}
+	}
 }
 
 void MainController::handleQuitRequest() {
diff --git a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h
index 4ebf1f1..d294fe8 100644
--- a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h
+++ b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h
@@ -14,7 +14,7 @@
 namespace Swift {
 	class JoinMUCUIEvent : public UIEvent {
 		public:
-			JoinMUCUIEvent(const JID& jid, const boost::optional<String>& nick) : jid_(jid), nick_(nick) {};
+			JoinMUCUIEvent(const JID& jid, const boost::optional<String>& nick = boost::optional<String>()) : jid_(jid), nick_(nick) {};
 			boost::optional<String> getNick() {return nick_;};
 			JID getJID() {return jid_;};
 		private:
-- 
cgit v0.10.2-6-g49f6