diff options
| author | Tobias Markmann <tm@ayena.de> | 2014-10-23 12:24:36 (GMT) | 
|---|---|---|
| committer | Tobias Markmann <tm@ayena.de> | 2014-10-23 12:24:36 (GMT) | 
| commit | fa67c2b239d9c7fc508205ea17724322011194f4 (patch) | |
| tree | 33c09d0a38bbf2a61b9f0dbadc048d7665542972 /Sluift | |
| parent | 052190912463d8ea36979fd5a5e9a298588dce4f (diff) | |
| download | swift-contrib-fa67c2b239d9c7fc508205ea17724322011194f4.zip swift-contrib-fa67c2b239d9c7fc508205ea17724322011194f4.tar.bz2 | |
Fix code in response to clang warnings.
Removes some unused private members and restructure switch statement to handle
all cases.
Test-Information:
Fixed code does not emit the clang warnings anymore.
Change-Id: I06a9036b307014e2f882e3cee45a6881b24c3f70
Diffstat (limited to 'Sluift')
| -rw-r--r-- | Sluift/ElementConvertors/StatusShowConvertor.cpp | 14 | ||||
| -rw-r--r-- | Sluift/Helpers.cpp | 35 | ||||
| -rw-r--r-- | Sluift/Helpers.h | 1 | ||||
| -rw-r--r-- | Sluift/SluiftComponent.cpp | 2 | ||||
| -rw-r--r-- | Sluift/SluiftComponent.h | 1 | 
5 files changed, 27 insertions, 26 deletions
| diff --git a/Sluift/ElementConvertors/StatusShowConvertor.cpp b/Sluift/ElementConvertors/StatusShowConvertor.cpp index d8e24ab..27876ff 100644 --- a/Sluift/ElementConvertors/StatusShowConvertor.cpp +++ b/Sluift/ElementConvertors/StatusShowConvertor.cpp @@ -26,33 +26,33 @@ boost::shared_ptr<StatusShow> StatusShowConvertor::doConvertFromLua(lua_State* L  	if (lua_isstring(L, -1)) {  		result->setType(convertStatusShowTypeFromString(lua_tostring(L, -1)));  	}  	lua_pop(L, 1);  	return result;  }  void StatusShowConvertor::doConvertToLua(lua_State* L, boost::shared_ptr<StatusShow> payload) {  	lua_createtable(L, 0, 0); -   	const std::string show = convertStatusShowTypeToString(payload->getType()); +	const std::string show = convertStatusShowTypeToString(payload->getType());  	if (!show.empty()) {  		lua_pushstring(L, show.c_str());  		lua_setfield(L, -2, "type");  	}  }  std::string StatusShowConvertor::convertStatusShowTypeToString(const StatusShow::Type &show) {  	switch (show) { -		case StatusShow::Online: return "online"; break; -		case StatusShow::FFC: return "ffc"; break; -		case StatusShow::Away: return "away"; break; -		case StatusShow::XA: return "xa"; break; -		case StatusShow::DND: return "dnd"; break; -		case StatusShow::None: return ""; break; +		case StatusShow::Online: return "online"; +		case StatusShow::FFC: return "ffc"; +		case StatusShow::Away: return "away"; +		case StatusShow::XA: return "xa"; +		case StatusShow::DND: return "dnd"; +		case StatusShow::None: return "";  	}  	assert(false);  	return "";  }  StatusShow::Type StatusShowConvertor::convertStatusShowTypeFromString(const std::string& show) {  	if (show == "online") {  		return StatusShow::Online;  	} diff --git a/Sluift/Helpers.cpp b/Sluift/Helpers.cpp index 29e2b04..756ae59 100644 --- a/Sluift/Helpers.cpp +++ b/Sluift/Helpers.cpp @@ -5,35 +5,28 @@   */  #include <Sluift/Helpers.h>  #include <Swiften/Client/ClientError.h>  #include <Swiften/Component/ComponentError.h>  using namespace Swift; -template<class T> std::string Swift::getCommonErrorString(T& error) { -	std::string reason = "Disconnected: "; -	switch(error.getType()) { -		case T::UnknownError: reason += "Unknown Error"; break; -		case T::ConnectionError: reason += "Error connecting to server"; break; -		case T::ConnectionReadError: reason += "Error while receiving server data"; break; -		case T::ConnectionWriteError: reason += "Error while sending data to the server"; break; -		case T::XMLError: reason += "Error parsing server data"; break; -		case T::AuthenticationFailedError: reason += "Login/password invalid"; break; -		case T::UnexpectedElementError: reason += "Unexpected response"; break; -	} -	return reason; -} -  std::string Swift::getErrorString(const ClientError& error) { -	std::string reason = getCommonErrorString(error); +	std::string reason = "Disconnected: ";  	switch(error.getType()) { +		case ClientError::UnknownError: reason += "Unknown Error"; break; +		case ClientError::ConnectionError: reason += "Error connecting to server"; break; +		case ClientError::ConnectionReadError: reason += "Error while receiving server data"; break; +		case ClientError::ConnectionWriteError: reason += "Error while sending data to the server"; break; +		case ClientError::XMLError: reason += "Error parsing server data"; break; +		case ClientError::AuthenticationFailedError: reason += "Login/password invalid"; break; +		case ClientError::UnexpectedElementError: reason += "Unexpected response"; break;  		case ClientError::DomainNameResolveError: reason += "Unable to find server"; break;  		case ClientError::CompressionFailedError: reason += "Error while compressing stream"; break;  		case ClientError::ServerVerificationFailedError: reason += "Server verification failed"; break;  		case ClientError::NoSupportedAuthMechanismsError: reason += "Authentication mechanisms not supported"; break;  		case ClientError::ResourceBindError: reason += "Error binding resource"; break;  		case ClientError::RevokedError: reason += "Certificate got revoked"; break;  		case ClientError::RevocationCheckFailedError: reason += "Failed to do revokation check"; break;  		case ClientError::SessionStartError: reason += "Error starting session"; break;  		case ClientError::StreamError: reason += "Stream error"; break; @@ -51,12 +44,22 @@ std::string Swift::getErrorString(const ClientError& error) {  		case ClientError::CertificatePathLengthExceededError: reason += "Certificate path length constraint exceeded"; break;  		case ClientError::InvalidCertificateSignatureError: reason += "Invalid certificate signature"; break;  		case ClientError::InvalidCAError: reason += "Invalid Certificate Authority"; break;  		case ClientError::InvalidServerIdentityError: reason += "Certificate does not match the host identity"; break;  	}  	return reason;  }  std::string Swift::getErrorString(const ComponentError& error) { -	return getCommonErrorString(error); +	std::string reason = "Disconnected: "; +	switch(error.getType()) { +		case ComponentError::UnknownError: reason += "Unknown Error"; break; +		case ComponentError::ConnectionError: reason += "Error connecting to server"; break; +		case ComponentError::ConnectionReadError: reason += "Error while receiving server data"; break; +		case ComponentError::ConnectionWriteError: reason += "Error while sending data to the server"; break; +		case ComponentError::XMLError: reason += "Error parsing server data"; break; +		case ComponentError::AuthenticationFailedError: reason += "Login/password invalid"; break; +		case ComponentError::UnexpectedElementError: reason += "Unexpected response"; break; +	} +	return reason;  } diff --git a/Sluift/Helpers.h b/Sluift/Helpers.h index d04a610..157e116 100644 --- a/Sluift/Helpers.h +++ b/Sluift/Helpers.h @@ -9,13 +9,12 @@  #include <Swiften/Base/Override.h>  #include <Swiften/Base/API.h>  #include <string>  namespace Swift {  	class ClientError;  	class ComponentError; -	template<typename T> std::string getCommonErrorString(T& error);  	std::string getErrorString(const ClientError& error);  	std::string getErrorString(const ComponentError& error);  } diff --git a/Sluift/SluiftComponent.cpp b/Sluift/SluiftComponent.cpp index c08a103..c8a17a7 100644 --- a/Sluift/SluiftComponent.cpp +++ b/Sluift/SluiftComponent.cpp @@ -73,19 +73,19 @@ bool SluiftComponent::isConnected() const {  }  void SluiftComponent::disconnect() {  	component->disconnect();  	while (component->isAvailable()) {  		eventLoop->runUntilEvents();  	}  } -void SluiftComponent::setSoftwareVersion(const std::string& name, const std::string& version, const std::string& os) { +void SluiftComponent::setSoftwareVersion(const std::string& name, const std::string& version, const std::string& /* os */) {  	component->setSoftwareVersion(name, version);  }  boost::optional<SluiftComponent::Event> SluiftComponent::getNextEvent(  		int timeout, boost::function<bool (const Event&)> condition) {  	Watchdog watchdog(timeout, networkFactories->getTimerFactory());  	size_t currentIndex = 0;  	while (true) {  		// Look for pending events in the queue diff --git a/Sluift/SluiftComponent.h b/Sluift/SluiftComponent.h index 3d5792b..ba848e1 100644 --- a/Sluift/SluiftComponent.h +++ b/Sluift/SluiftComponent.h @@ -92,17 +92,16 @@ namespace Swift {  			void handleIncomingPresence(boost::shared_ptr<Presence> stanza);  			void handleRequestResponse(boost::shared_ptr<Payload> response, boost::shared_ptr<ErrorPayload> error);  			void handleError(const boost::optional<ComponentError>& error);  		private:  			NetworkFactories* networkFactories;  			SimpleEventLoop* eventLoop;  			Component* component;  			ComponentXMLTracer* tracer; -			bool rosterReceived;  			std::deque<Event> pendingEvents;  			boost::optional<ComponentError> disconnectedError;  			bool requestResponseReceived;  			boost::shared_ptr<Payload> requestResponse;  			boost::shared_ptr<ErrorPayload> requestError;  	};  } | 
 Swift
 Swift