From 80a67051508b7a2f59e0ded9d1dd4df490d44ec2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Tue, 10 Nov 2009 22:39:38 +0100
Subject: Fixed error handling.


diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 6c60783..bc16922 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -266,7 +266,7 @@ void MainController::performLoginFromCachedCredentials() {
 void MainController::handleError(const ClientError& error) {
 	String message;
 	switch(error.getType()) {
-		case ClientError::NoError: assert(false); break;
+		case ClientError::UnknownError: message = "Unknown Error"; break;
 		case ClientError::DomainNameResolveError: message = "Unable to find server"; break;
 		case ClientError::ConnectionError: message = "Error connecting to server"; break;
 		case ClientError::ConnectionReadError: message = "Error while receiving server data"; break;
diff --git a/Swiften/Client/ClientError.h b/Swiften/Client/ClientError.h
index d81cc0e..d4f280c 100644
--- a/Swiften/Client/ClientError.h
+++ b/Swiften/Client/ClientError.h
@@ -1,11 +1,10 @@
-#ifndef SWIFTEN_ClientError_H
-#define SWIFTEN_ClientError_H
+#pragma once
 
 namespace Swift {
 	class ClientError {
 		public:
 			enum Type {
-				NoError,
+				UnknownError,
 				DomainNameResolveError,
 				ConnectionError,
 				ConnectionReadError,
@@ -21,7 +20,7 @@ namespace Swift {
 				ClientCertificateError
 			};
 
-			ClientError(Type type = NoError) : type_(type) {}
+			ClientError(Type type = UnknownError) : type_(type) {}
 
 			Type getType() const { return type_; }
 
@@ -29,5 +28,3 @@ namespace Swift {
 			Type type_;
 	};
 }
-
-#endif
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index 8b14367..807470e 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -75,14 +75,14 @@ void BasicSessionStream::addTLSEncryption() {
 }
 
 void BasicSessionStream::setWhitespacePingEnabled(bool enabled) {
-	if (enabled && !whitespacePingLayer) {
-		whitespacePingLayer = boost::shared_ptr<WhitespacePingLayer>(new WhitespacePingLayer());
-		streamStack->addLayer(whitespacePingLayer);
-	}
 	if (enabled) {
+		if (!whitespacePingLayer) {
+			whitespacePingLayer = boost::shared_ptr<WhitespacePingLayer>(new WhitespacePingLayer());
+			streamStack->addLayer(whitespacePingLayer);
+		}
 		whitespacePingLayer->setActive();
 	}
-	else {
+	else if (whitespacePingLayer) {
 		whitespacePingLayer->setInactive();
 	}
 }
-- 
cgit v0.10.2-6-g49f6