From dc48cc3f34e3e229172202717520e77233c37ed7 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Tue, 16 Sep 2014 14:23:24 +0100
Subject: Fix boost::optional abuses that stop compilation with latest boost

Test-Information:
Compiles and unit tests pass with boost 1.56

Change-Id: I6525399babc5f6c88fb499af80e9f07c1c4d0cdb

diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index e309265..17214e4 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -308,7 +308,7 @@ void QtUserSearchWindow::setSearchFields(boost::shared_ptr<SearchPayload> fields
 		fieldsPage_->setFormWidget(new QtFormWidget(fields->getForm(), fieldsPage_));
 	} else {
 		fieldsPage_->setFormWidget(NULL);
-		bool enabled[8] = {fields->getNick(), fields->getNick(), fields->getFirst(), fields->getFirst(), fields->getLast(), fields->getLast(), fields->getEMail(), fields->getEMail()};
+		bool enabled[8] = {!!fields->getNick(), !!fields->getNick(), !!fields->getFirst(), !!fields->getFirst(), !!fields->getLast(), !!fields->getLast(), !!fields->getEMail(), !!fields->getEMail()};
 		QWidget* legacySearchWidgets[8] = {fieldsPage_->nickInputLabel_, fieldsPage_->nickInput_, fieldsPage_->firstInputLabel_, fieldsPage_->firstInput_, fieldsPage_->lastInputLabel_, fieldsPage_->lastInput_, fieldsPage_->emailInputLabel_, fieldsPage_->emailInput_};
 		for (int i = 0; i < 8; i++) {
 			legacySearchWidgets[i]->setVisible(enabled[i]);
diff --git a/Swiften/Avatars/CombinedAvatarProvider.cpp b/Swiften/Avatars/CombinedAvatarProvider.cpp
index 1bd74dd..30f9f52 100644
--- a/Swiften/Avatars/CombinedAvatarProvider.cpp
+++ b/Swiften/Avatars/CombinedAvatarProvider.cpp
@@ -38,7 +38,7 @@ void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) {
 	}
 	boost::optional<std::string> newHash = getCombinedAvatarAndCache(jid);
 	if (newHash != oldHash) {
-		SWIFT_LOG(debug) << "Avatar changed: " << jid << ": " << oldHash << " -> " << newHash << std::endl;
+		SWIFT_LOG(debug) << "Avatar changed: " << jid << ": " << oldHash << " -> " << (newHash ? newHash.get() : "NULL") << std::endl;
 		onAvatarChanged(jid);
 	}
 }
@@ -48,7 +48,7 @@ boost::optional<std::string> CombinedAvatarProvider::getCombinedAvatarAndCache(c
 	boost::optional<std::string> hash;
 	for (size_t i = 0; i < providers.size() && !hash; ++i) {
 		hash = providers[i]->getAvatarHash(jid);
-		SWIFT_LOG(debug) << "Provider " << providers[i] << ": " << hash << std::endl;
+		SWIFT_LOG(debug) << "Provider " << providers[i] << ": " << (hash ? hash.get() : "NULL") << std::endl;
 	}
 	if (hash) {
 		avatars[jid] = *hash;
diff --git a/Swiften/Examples/NetworkTool/main.cpp b/Swiften/Examples/NetworkTool/main.cpp
index 10a0aa6..77ba3f6 100644
--- a/Swiften/Examples/NetworkTool/main.cpp
+++ b/Swiften/Examples/NetworkTool/main.cpp
@@ -38,8 +38,8 @@ static void handleGetForwardPortRequestResponse(const boost::optional<NATPortMap
 	eventLoop.stop();
 }
 
-static void handleRemovePortForwardingRequestResponse(bool result) {
-	if (result) {
+static void handleRemovePortForwardingRequestResponse(const boost::optional<bool> result) {
+	if (result && result.get()) {
 		std::cerr << "Result: OK" << std::endl;
 	}
 	else {
diff --git a/Swiften/QA/ClientTest/ClientTest.cpp b/Swiften/QA/ClientTest/ClientTest.cpp
index e88e5ac..38f70db 100644
--- a/Swiften/QA/ClientTest/ClientTest.cpp
+++ b/Swiften/QA/ClientTest/ClientTest.cpp
@@ -31,7 +31,7 @@ static TestStage stage;
 static ClientOptions options;
 
 static void handleDisconnected(boost::optional<ClientError> e) {
-	std::cout << "Disconnected: " << e << std::endl;
+	std::cout << "Disconnected: " << (e ? e.get().getType() : ClientError::UnknownError) << std::endl;
 	if (stage == FirstConnect) {
 		stage = Reconnect;
 		client->connect(options);
diff --git a/Swiften/Serializer/StreamResumeSerializer.cpp b/Swiften/Serializer/StreamResumeSerializer.cpp
index 902ab21..229b826 100644
--- a/Swiften/Serializer/StreamResumeSerializer.cpp
+++ b/Swiften/Serializer/StreamResumeSerializer.cpp
@@ -22,7 +22,7 @@ SafeByteArray StreamResumeSerializer::serialize(boost::shared_ptr<ToplevelElemen
 	XMLElement element("resume", "urn:xmpp:sm:2");
 	element.setAttribute("previd", e->getResumeID());
 	if (e->getHandledStanzasCount()) {
-		element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount()));
+		element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get()));
 	}
 	return createSafeByteArray(element.serialize());
 }
diff --git a/Swiften/Serializer/StreamResumedSerializer.cpp b/Swiften/Serializer/StreamResumedSerializer.cpp
index 6477af9..48dbe8f 100644
--- a/Swiften/Serializer/StreamResumedSerializer.cpp
+++ b/Swiften/Serializer/StreamResumedSerializer.cpp
@@ -22,7 +22,7 @@ SafeByteArray StreamResumedSerializer::serialize(boost::shared_ptr<ToplevelEleme
 	XMLElement element("resumed", "urn:xmpp:sm:2");
 	element.setAttribute("previd", e->getResumeID());
 	if (e->getHandledStanzasCount()) {
-		element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount()));
+		element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get()));
 	}
 	return createSafeByteArray(element.serialize());
 }
-- 
cgit v0.10.2-6-g49f6