diff options
| author | Kevin Smith <git@kismith.co.uk> | 2011-11-12 16:56:21 (GMT) | 
|---|---|---|
| committer | Kevin Smith <git@kismith.co.uk> | 2011-12-13 08:17:58 (GMT) | 
| commit | 81c09a0f6a3e87b078340d7f35d0dea4c03f3a6d (patch) | |
| tree | 4371c5808ee26b2b5ed79ace9ccb439ff2988945 /Swiften/Client/ClientXMLTracer.cpp | |
| parent | fd17fe0d239f97cedebe4ceffa234155bd299b68 (diff) | |
| download | swift-contrib-81c09a0f6a3e87b078340d7f35d0dea4c03f3a6d.zip swift-contrib-81c09a0f6a3e87b078340d7f35d0dea4c03f3a6d.tar.bz2  | |
BOSH Support for Swiften
This adds support for BOSH to Swiften. It does not expose it to Swift.
Release-Notes: Swiften now allows connects over BOSH, if used appropriately.
Diffstat (limited to 'Swiften/Client/ClientXMLTracer.cpp')
| -rw-r--r-- | Swiften/Client/ClientXMLTracer.cpp | 17 | 
1 files changed, 15 insertions, 2 deletions
diff --git a/Swiften/Client/ClientXMLTracer.cpp b/Swiften/Client/ClientXMLTracer.cpp index c1093eb..405e3d1 100644 --- a/Swiften/Client/ClientXMLTracer.cpp +++ b/Swiften/Client/ClientXMLTracer.cpp @@ -11,7 +11,7 @@  namespace Swift { -ClientXMLTracer::ClientXMLTracer(CoreClient* client) { +ClientXMLTracer::ClientXMLTracer(CoreClient* client, bool bosh) : bosh(bosh) {  	beautifier = new XMLBeautifier(true, true);  	client->onDataRead.connect(boost::bind(&ClientXMLTracer::printData, this, '<', _1));  	client->onDataWritten.connect(boost::bind(&ClientXMLTracer::printData, this, '>', _1)); @@ -23,7 +23,20 @@ ClientXMLTracer::~ClientXMLTracer() {  void ClientXMLTracer::printData(char direction, const SafeByteArray& data) {  	printLine(direction); -	std::cerr << beautifier->beautify(byteArrayToString(ByteArray(data.begin(), data.end()))) << std::endl; +	if (bosh) { +		std::string line = byteArrayToString(ByteArray(data.begin(), data.end()));  +		size_t endOfHTTP = line.find("\r\n\r\n"); +		if (false && endOfHTTP != std::string::npos) { +			/* Disabled because it swallows bits of XML (namespaces, if I recall) */ +			std::cerr << line.substr(0, endOfHTTP) << std::endl << beautifier->beautify(line.substr(endOfHTTP)) << std::endl; +		} +		else { +			std::cerr << line << std::endl; +		} +	} +	else { +		std::cerr << beautifier->beautify(byteArrayToString(ByteArray(data.begin(), data.end()))) << std::endl; +	}  }  void ClientXMLTracer::printLine(char c) {  | 
 Swift