From 534b7771cbfdee2fa60f6f154d578c3ef8cf2563 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 28 Apr 2012 12:06:38 +0100
Subject: Send label catalogue queries to bare/full JID as appropriate.

Resolves: #244

diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 5a18a98..2fa4559 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -91,6 +91,10 @@ ChatController::~ChatController() {
 	delete chatStateTracker_;
 }
 
+JID ChatController::getBaseJID() {
+	return isInMUC_ ? toJID_ : ChatControllerBase::getBaseJID();
+}
+
 void ChatController::cancelReplaces() {
 	lastWasPresence_ = false;
 }
diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h
index 00d167e..7043231 100644
--- a/Swift/Controllers/Chat/ChatController.h
+++ b/Swift/Controllers/Chat/ChatController.h
@@ -33,6 +33,7 @@ namespace Swift {
 
 		protected:
 			void cancelReplaces();
+			JID getBaseJID();
 
 		private:
 			void handlePresenceChange(boost::shared_ptr<Presence> newPresence);
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index 3ff52a6..bc9c14e 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2011 Kevin Smith
+ * Copyright (c) 2010-2012 Kevin Smith
  * Licensed under the GNU General Public License v3.
  * See Documentation/Licenses/GPLv3.txt for more information.
  */
@@ -84,9 +84,13 @@ void ChatControllerBase::setOnline(bool online) {
 	setEnabled(online);
 }
 
+JID ChatControllerBase::getBaseJID() {
+	return JID(toJID_.toBare());
+}
+
 void ChatControllerBase::setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> info) {
 	if (iqRouter_->isAvailable() && info->hasFeature(DiscoInfo::SecurityLabelsCatalogFeature)) {
-		GetSecurityLabelsCatalogRequest::ref request = GetSecurityLabelsCatalogRequest::create(JID(toJID_.toBare()), iqRouter_);
+		GetSecurityLabelsCatalogRequest::ref request = GetSecurityLabelsCatalogRequest::create(getBaseJID(), iqRouter_);
 		request->onResponse.connect(boost::bind(&ChatControllerBase::handleSecurityLabelsCatalogResponse, this, _1, _2));
 		request->send();
 	} else {
diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h
index 8654311..b698581 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.h
+++ b/Swift/Controllers/Chat/ChatControllerBase.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Kevin Smith
+ * Copyright (c) 2010-2012 Kevin Smith
  * Licensed under the GNU General Public License v3.
  * See Documentation/Licenses/GPLv3.txt for more information.
  */
@@ -76,6 +76,8 @@ namespace Swift {
 			std::string getErrorMessage(boost::shared_ptr<ErrorPayload>);
 			virtual void setContactIsReceivingPresence(bool /* isReceivingPresence */) {}
 			virtual void cancelReplaces() = 0;
+			/** JID any iq for account should go to - bare except for PMs */
+			virtual JID getBaseJID();
 
 		private:
 			IDGenerator idGenerator_;
-- 
cgit v0.10.2-6-g49f6