From dcf30da8e1bf6c3e42f9d0ac8adbdb14f77a9622 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sun, 10 Oct 2010 20:01:30 +0200
Subject: Move SoftwareVersion responder from Swift to Client.


diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index c219ae9..d7801f3 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -47,7 +47,6 @@
 #include "Swiften/Elements/ChatState.h"
 #include "Swiften/Elements/Presence.h"
 #include "Swiften/Elements/VCardUpdate.h"
-#include "Swiften/Queries/Responders/SoftwareVersionResponder.h"
 #include "Swift/Controllers/Settings/SettingsProvider.h"
 #include "Swiften/Elements/DiscoInfo.h"
 #include "Swiften/Queries/Responders/DiscoInfoResponder.h"
@@ -116,7 +115,6 @@ MainController::MainController(
 	xmppRosterController_ = NULL;
 	chatsManager_ = NULL;
 	eventWindowController_ = NULL;
-	clientVersionResponder_ = NULL;
 	discoResponder_ = NULL;
 	mucSearchController_ = NULL;
 
@@ -201,11 +199,6 @@ void MainController::resetClient() {
 		delete discoResponder_;
 		discoResponder_ = NULL;
 	}
-	if (clientVersionResponder_) {
-		clientVersionResponder_->stop();
-		delete clientVersionResponder_;
-		clientVersionResponder_ = NULL;
-	}
 	delete eventWindowController_;
 	eventWindowController_ = NULL;
 	delete xmppRosterController_;
@@ -293,9 +286,6 @@ void MainController::handleConnected() {
 
 		eventWindowController_ = new EventWindowController(eventController_, eventWindowFactory_);
 
-		clientVersionResponder_ = new SoftwareVersionResponder(client_->getIQRouter());
-		clientVersionResponder_->setVersion(CLIENT_NAME, buildVersion);
-		clientVersionResponder_->start();
 		loginWindow_->morphInto(rosterController_->getWindow());
 
 		DiscoInfo discoInfo;
@@ -420,6 +410,9 @@ void MainController::performLoginFromCachedCredentials() {
 	}
 	if (!client_) {
 		client_ = new Swift::Client(jid_, password_);
+
+		client_->setSoftwareVersion(CLIENT_NAME, buildVersion);
+
 		presenceSender_ = new PresenceSender(client_->getStanzaChannel());
 		presenceOracle_ = new PresenceOracle(client_->getStanzaChannel());
 		mucRegistry_ = new MUCRegistry();
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 0887007..fb26a9d 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -52,7 +52,6 @@ namespace Swift {
 	class EntityCapsManager;
 	class LoginWindow;
 	class EventLoop;
-	class SoftwareVersionResponder;
 	class LoginWindowFactory;
 	class MUCController;
 	class Notifier;
@@ -149,7 +148,6 @@ namespace Swift {
 			EventController* eventController_;
 			EventWindowController* eventWindowController_;
 			LoginWindow* loginWindow_;
-			SoftwareVersionResponder* clientVersionResponder_;
 			NickResolver* nickResolver_;
 			DiscoInfoResponder* discoResponder_;
 			UIEventStream* uiEventStream_;
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 44804be..5c64506 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -6,9 +6,22 @@
 
 #include "Swiften/Client/Client.h"
 
+#include "Swiften/Queries/Responders/SoftwareVersionResponder.h"
+
 namespace Swift {
 
 Client::Client(const JID& jid, const String& password) : CoreClient(jid, password) {
+	softwareVersionResponder = new SoftwareVersionResponder(getIQRouter());
+	softwareVersionResponder->start();
+}
+
+Client::~Client() {
+	softwareVersionResponder->stop();
+	delete softwareVersionResponder;
+}
+
+void Client::setSoftwareVersion(const String& name, const String& version) {
+	softwareVersionResponder->setVersion(name, version);
 }
 
 }
diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h
index 7609eb8..54d6e56 100644
--- a/Swiften/Client/Client.h
+++ b/Swiften/Client/Client.h
@@ -9,8 +9,29 @@
 #include "Swiften/Client/CoreClient.h"
 
 namespace Swift {
+	class SoftwareVersionResponder;
+
+	/**
+	 * Provides the core functionality for writing XMPP client software.
+	 *
+	 * Besides connecting to an XMPP server, this class also provides interfaces for
+	 * performing most tasks on the XMPP network.
+	 */
 	class Client : public CoreClient {
 		public:
 			Client(const JID& jid, const String& password);
+			~Client();
+
+
+			/**
+			 * Sets the software version of the client.
+			 *
+			 * This will be used to respond to version queries from other entities.
+			 */
+			void setSoftwareVersion(const String& name, const String& version);
+
+		private:
+			SoftwareVersionResponder* softwareVersionResponder;
+
 	};
 }
diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h
index 704cf3b..02d98b6 100644
--- a/Swiften/Client/CoreClient.h
+++ b/Swiften/Client/CoreClient.h
@@ -32,6 +32,15 @@ namespace Swift {
 	class ClientSession;
 	class BasicSessionStream;
 
+	/**
+	 * The central class for communicating with an XMPP server.
+	 *
+	 * This class is responsible for setting up the connection with the XMPP server, authenticating, and
+	 * initializing the session.
+	 *
+	 * This class can be used directly in your application, although the Client subclass provides more
+	 * functionality and interfaces, and is better suited for most needs.
+	 */
 	class CoreClient  {
 		public:
 			CoreClient(const JID& jid, const String& password);
-- 
cgit v0.10.2-6-g49f6