Changeset - fe74083e2e3c
[Not reviewed]
0 2 0
HanzZ - 14 years ago 2011-12-10 15:44:43
hanzz.k@gmail.com
Do not try to serialize something what is not Storage element
2 files changed with 16 insertions and 6 deletions:
0 comments (0 inline, 0 general)
include/transport/pqxxbackend.h
Show inline comments
 
@@ -27,7 +27,7 @@
 
#include "Swiften/Swiften.h"
 
#include "transport/storagebackend.h"
 
#include "transport/config.h"
 
#include "mysql.h"
 
#include <pqxx/pqxx>
 

	
 
namespace Transport {
 

	
 
@@ -99,6 +99,8 @@ class PQXXBackend : public StorageBackend
 
		bool exec(const std::string &query);
 
		Config *m_config;
 
		std::string m_prefix;
 

	
 
		pqxx::connection *m_conn;
 
};
 

	
 
}
src/storageresponder.cpp
Show inline comments
 
@@ -71,11 +71,19 @@ bool StorageResponder::handleSetRequest(const Swift::JID& from, const Swift::JID
 
		return true;
 
	}
 

	
 
	StorageSerializer serializer;
 
	std::string value = serializer.serializePayload(boost::dynamic_pointer_cast<Storage>(payload->getPayload()));
 
	m_storageBackend->updateUserSetting(user->getUserInfo().id, "storage", value);
 
	LOG4CXX_INFO(logger, from.toBare().toString() << ": Storing jabber:iq:storage");
 
	sendResponse(from, id, boost::shared_ptr<PrivateStorage>());
 
	boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload());
 

	
 
	if (storage) {
 
		StorageSerializer serializer;
 
		std::string value = serializer.serializePayload(boost::dynamic_pointer_cast<Storage>(payload->getPayload()));
 
		m_storageBackend->updateUserSetting(user->getUserInfo().id, "storage", value);
 
		LOG4CXX_INFO(logger, from.toBare().toString() << ": Storing jabber:iq:storage");
 
		sendResponse(from, id, boost::shared_ptr<PrivateStorage>());
 
	}
 
	else {
 
		LOG4CXX_INFO(logger, from.toBare().toString() << ": Unknown element. Libtransport does not support serialization of this.");
 
		sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Cancel);
 
	}
 
	return true;
 
}
 

	
0 comments (0 inline, 0 general)