From 9c6f742cbb729ecd4f78c33f5b630f670f976715 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Wed, 8 Jun 2011 21:10:13 +0200
Subject: Added AllowPlainOverNONTLS option to ClientOptions.


diff --git a/Swiften/Client/ClientOptions.h b/Swiften/Client/ClientOptions.h
index cc80dc2..0766402 100644
--- a/Swiften/Client/ClientOptions.h
+++ b/Swiften/Client/ClientOptions.h
@@ -6,44 +6,53 @@
 
 #pragma once
 
-struct ClientOptions {
-	enum UseTLS {
-		NeverUseTLS,
-		UseTLSWhenAvailable
+namespace Swift {
+	struct ClientOptions {
+		enum UseTLS {
+			NeverUseTLS,
+			UseTLSWhenAvailable
+		};
+
+		ClientOptions() : useStreamCompression(true), useTLS(UseTLSWhenAvailable), allowPLAINWithoutTLS(false), useStreamResumption(false), forgetPassword(false) {
+		}
+
+		/**
+		 * Whether ZLib stream compression should be used when available.
+		 *
+		 * Default: true
+		 */
+		bool useStreamCompression;
+
+		/**
+		 * Sets whether TLS encryption should be used.
+		 *
+		 * Default: UseTLSWhenAvailable
+		 */
+		UseTLS useTLS;
+
+		/**
+		 * Sets whether plaintext authentication is 
+		 * allowed over non-TLS-encrypted connections.
+		 *
+		 * Default: false
+		 */
+		bool allowPLAINWithoutTLS;
+
+		/**
+		 * Use XEP-196 stream resumption when available.
+		 *
+		 * Default: false
+		 */
+		bool useStreamResumption;
+
+		/**
+		 * Forget the password once it's used.
+		 * This makes the Client useless after the first login attempt.
+		 *
+		 * FIXME: This is a temporary workaround.
+		 *
+		 * Default: false
+		 */
+		bool forgetPassword;
 	};
-
-	ClientOptions() : useStreamCompression(true), useTLS(UseTLSWhenAvailable), useStreamResumption(false), forgetPassword(false) {
-	}
-
-	/**
-	 * Whether ZLib stream compression should be used when available.
-	 *
-	 * Default: true
-	 */
-	bool useStreamCompression;
-
-	/**
-	 * Sets whether TLS encryption should be used.
-	 *
-	 * Default: UseTLSWhenAvailable
-	 */
-	UseTLS useTLS;
-
-	/**
-	 * Use XEP-196 stream resumption when available.
-	 *
-	 * Default: false
-	 */
-	bool useStreamResumption;
-
-	/**
-	 * Forget the password once it's used.
-	 * This makes the Client useless after the first login attempt.
-	 *
-	 * FIXME: This is a temporary workaround.
-	 *
-	 * Default: false
-	 */
-	bool forgetPassword;
-};
-
+}
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index a2708c5..ab9e947 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -109,6 +109,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio
 		session_ = ClientSession::create(jid_, sessionStream_);
 		session_->setCertificateTrustChecker(certificateTrustChecker);
 		session_->setUseStreamCompression(options.useStreamCompression);
+		session_->setAllowPLAINOverNonTLS(options.allowPLAINWithoutTLS);
 		switch(options.useTLS) {
 			case ClientOptions::UseTLSWhenAvailable:
 				session_->setUseTLS(ClientSession::UseTLSWhenAvailable);
-- 
cgit v0.10.2-6-g49f6