summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-15 20:40:51 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-15 20:40:51 (GMT)
commita49ca97a7b2ad61385d0f6f22ec598a63d889ae7 (patch)
tree332ff85114c4bc6cea5a028a10c111786584be57 /Swiften/Component
parent10d8877b9251d5408da9ac3a5eafb066de121bc6 (diff)
downloadswift-a49ca97a7b2ad61385d0f6f22ec598a63d889ae7.zip
swift-a49ca97a7b2ad61385d0f6f22ec598a63d889ae7.tar.bz2
Added EchoComponent.
Diffstat (limited to 'Swiften/Component')
-rw-r--r--Swiften/Component/ComponentXMLTracer.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/Swiften/Component/ComponentXMLTracer.h b/Swiften/Component/ComponentXMLTracer.h
new file mode 100644
index 0000000..512e69c
--- /dev/null
+++ b/Swiften/Component/ComponentXMLTracer.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <boost/bind.hpp>
+
+#include "Swiften/Component/Component.h"
+
+namespace Swift {
+ class ComponentXMLTracer {
+ public:
+ ComponentXMLTracer(Component* component) {
+ component->onDataRead.connect(boost::bind(&ComponentXMLTracer::printData, '<', _1));
+ component->onDataWritten.connect(boost::bind(&ComponentXMLTracer::printData, '>', _1));
+ }
+
+ private:
+ static void printData(char direction, const String& data) {
+ printLine(direction);
+ std::cerr << data << std::endl;
+ }
+
+ static void printLine(char c) {
+ for (unsigned int i = 0; i < 80; ++i) {
+ std::cerr << c;
+ }
+ std::cerr << std::endl;
+ }
+ };
+}