diff options
Diffstat (limited to 'Swiften/Component')
-rw-r--r-- | Swiften/Component/Component.cpp | 4 | ||||
-rw-r--r-- | Swiften/Component/Component.h | 2 | ||||
-rw-r--r-- | Swiften/Component/ComponentConnector.cpp | 10 | ||||
-rw-r--r-- | Swiften/Component/ComponentConnector.h | 12 | ||||
-rw-r--r-- | Swiften/Component/ComponentHandshakeGenerator.cpp | 8 | ||||
-rw-r--r-- | Swiften/Component/ComponentSession.cpp | 10 | ||||
-rw-r--r-- | Swiften/Component/ComponentSession.h | 12 | ||||
-rw-r--r-- | Swiften/Component/ComponentSessionStanzaChannel.cpp | 3 | ||||
-rw-r--r-- | Swiften/Component/ComponentSessionStanzaChannel.h | 12 | ||||
-rw-r--r-- | Swiften/Component/ComponentXMLTracer.cpp | 31 | ||||
-rw-r--r-- | Swiften/Component/ComponentXMLTracer.h | 22 | ||||
-rw-r--r-- | Swiften/Component/CoreComponent.cpp | 23 | ||||
-rw-r--r-- | Swiften/Component/CoreComponent.h | 33 | ||||
-rw-r--r-- | Swiften/Component/SConscript | 1 | ||||
-rw-r--r-- | Swiften/Component/UnitTest/ComponentConnectorTest.cpp | 16 | ||||
-rw-r--r-- | Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp | 2 | ||||
-rw-r--r-- | Swiften/Component/UnitTest/ComponentSessionTest.cpp | 10 |
17 files changed, 116 insertions, 95 deletions
diff --git a/Swiften/Component/Component.cpp b/Swiften/Component/Component.cpp index fb4ba4c..af378a7 100644 --- a/Swiften/Component/Component.cpp +++ b/Swiften/Component/Component.cpp @@ -4,9 +4,9 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Component/Component.h" +#include <Swiften/Component/Component.h> -#include "Swiften/Queries/Responders/SoftwareVersionResponder.h" +#include <Swiften/Queries/Responders/SoftwareVersionResponder.h> namespace Swift { diff --git a/Swiften/Component/Component.h b/Swiften/Component/Component.h index 0119db0..0b29ff7 100644 --- a/Swiften/Component/Component.h +++ b/Swiften/Component/Component.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Component/CoreComponent.h" +#include <Swiften/Component/CoreComponent.h> namespace Swift { class SoftwareVersionResponder; diff --git a/Swiften/Component/ComponentConnector.cpp b/Swiften/Component/ComponentConnector.cpp index 2af45f6..b7bdd34 100644 --- a/Swiften/Component/ComponentConnector.cpp +++ b/Swiften/Component/ComponentConnector.cpp @@ -4,15 +4,15 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Component/ComponentConnector.h" +#include <Swiften/Component/ComponentConnector.h> #include <boost/bind.hpp> #include <iostream> -#include "Swiften/Network/ConnectionFactory.h" -#include "Swiften/Network/DomainNameResolver.h" -#include "Swiften/Network/DomainNameAddressQuery.h" -#include "Swiften/Network/TimerFactory.h" +#include <Swiften/Network/ConnectionFactory.h> +#include <Swiften/Network/DomainNameResolver.h> +#include <Swiften/Network/DomainNameAddressQuery.h> +#include <Swiften/Network/TimerFactory.h> namespace Swift { diff --git a/Swiften/Component/ComponentConnector.h b/Swiften/Component/ComponentConnector.h index c5e8f80..b47f5da 100644 --- a/Swiften/Component/ComponentConnector.h +++ b/Swiften/Component/ComponentConnector.h @@ -7,14 +7,14 @@ #pragma once #include <deque> -#include "Swiften/Base/boost_bsignals.h" +#include <Swiften/Base/boost_bsignals.h> #include <boost/shared_ptr.hpp> -#include "Swiften/Network/Connection.h" -#include "Swiften/Network/Timer.h" -#include "Swiften/Network/HostAddressPort.h" +#include <Swiften/Network/Connection.h> +#include <Swiften/Network/Timer.h> +#include <Swiften/Network/HostAddressPort.h> #include <string> -#include "Swiften/Network/DomainNameResolveError.h" +#include <Swiften/Network/DomainNameResolveError.h> namespace Swift { class DomainNameAddressQuery; @@ -27,7 +27,7 @@ namespace Swift { typedef boost::shared_ptr<ComponentConnector> ref; static ComponentConnector::ref create(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { - return ComponentConnector::ref(new ComponentConnector(hostname, port, resolver, connectionFactory, timerFactory)); + return ref(new ComponentConnector(hostname, port, resolver, connectionFactory, timerFactory)); } void setTimeoutMilliseconds(int milliseconds); diff --git a/Swiften/Component/ComponentHandshakeGenerator.cpp b/Swiften/Component/ComponentHandshakeGenerator.cpp index 4081420..79ba9b3 100644 --- a/Swiften/Component/ComponentHandshakeGenerator.cpp +++ b/Swiften/Component/ComponentHandshakeGenerator.cpp @@ -4,9 +4,9 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Component/ComponentHandshakeGenerator.h" -#include "Swiften/StringCodecs/Hexify.h" -#include "Swiften/StringCodecs/SHA1.h" +#include <Swiften/Component/ComponentHandshakeGenerator.h> +#include <Swiften/StringCodecs/Hexify.h> +#include <Swiften/StringCodecs/SHA1.h> #include <Swiften/Base/String.h> namespace Swift { @@ -18,7 +18,7 @@ std::string ComponentHandshakeGenerator::getHandshake(const std::string& streamI String::replaceAll(concatenatedString, '>', ">"); String::replaceAll(concatenatedString, '\'', "'"); String::replaceAll(concatenatedString, '"', """); - return Hexify::hexify(SHA1::getHash(ByteArray(concatenatedString))); + return Hexify::hexify(SHA1::getHash(createByteArray(concatenatedString))); } } diff --git a/Swiften/Component/ComponentSession.cpp b/Swiften/Component/ComponentSession.cpp index 17e0dfd..af11146 100644 --- a/Swiften/Component/ComponentSession.cpp +++ b/Swiften/Component/ComponentSession.cpp @@ -4,14 +4,14 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Component/ComponentSession.h" +#include <Swiften/Component/ComponentSession.h> #include <boost/bind.hpp> -#include "Swiften/Elements/ProtocolHeader.h" -#include "Swiften/Elements/ComponentHandshake.h" -#include "Swiften/Session/SessionStream.h" -#include "Swiften/Component/ComponentHandshakeGenerator.h" +#include <Swiften/Elements/ProtocolHeader.h> +#include <Swiften/Elements/ComponentHandshake.h> +#include <Swiften/Session/SessionStream.h> +#include <Swiften/Component/ComponentHandshakeGenerator.h> namespace Swift { diff --git a/Swiften/Component/ComponentSession.h b/Swiften/Component/ComponentSession.h index 168e618..647bad7 100644 --- a/Swiften/Component/ComponentSession.h +++ b/Swiften/Component/ComponentSession.h @@ -9,13 +9,13 @@ #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> -#include "Swiften/JID/JID.h" -#include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/Error.h" +#include <Swiften/JID/JID.h> +#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/Base/Error.h> #include <string> -#include "Swiften/Elements/Element.h" -#include "Swiften/Elements/Stanza.h" -#include "Swiften/Session/SessionStream.h" +#include <Swiften/Elements/Element.h> +#include <Swiften/Elements/Stanza.h> +#include <Swiften/Session/SessionStream.h> namespace Swift { class ComponentAuthenticator; diff --git a/Swiften/Component/ComponentSessionStanzaChannel.cpp b/Swiften/Component/ComponentSessionStanzaChannel.cpp index b9fecb2..3e96dce 100644 --- a/Swiften/Component/ComponentSessionStanzaChannel.cpp +++ b/Swiften/Component/ComponentSessionStanzaChannel.cpp @@ -4,9 +4,10 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Component/ComponentSessionStanzaChannel.h" +#include <Swiften/Component/ComponentSessionStanzaChannel.h> #include <boost/bind.hpp> +#include <iostream> namespace Swift { diff --git a/Swiften/Component/ComponentSessionStanzaChannel.h b/Swiften/Component/ComponentSessionStanzaChannel.h index 605c8dc..45f90b5 100644 --- a/Swiften/Component/ComponentSessionStanzaChannel.h +++ b/Swiften/Component/ComponentSessionStanzaChannel.h @@ -8,12 +8,12 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/IDGenerator.h" -#include "Swiften/Component/ComponentSession.h" -#include "Swiften/Client/StanzaChannel.h" -#include "Swiften/Elements/Message.h" -#include "Swiften/Elements/IQ.h" -#include "Swiften/Elements/Presence.h" +#include <Swiften/Base/IDGenerator.h> +#include <Swiften/Component/ComponentSession.h> +#include <Swiften/Client/StanzaChannel.h> +#include <Swiften/Elements/Message.h> +#include <Swiften/Elements/IQ.h> +#include <Swiften/Elements/Presence.h> namespace Swift { /** diff --git a/Swiften/Component/ComponentXMLTracer.cpp b/Swiften/Component/ComponentXMLTracer.cpp new file mode 100644 index 0000000..d77eef7 --- /dev/null +++ b/Swiften/Component/ComponentXMLTracer.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <Swiften/Component/ComponentXMLTracer.h> + +#include <iostream> +#include <boost/bind.hpp> + +namespace Swift { + +ComponentXMLTracer::ComponentXMLTracer(CoreComponent* client) { + client->onDataRead.connect(boost::bind(&ComponentXMLTracer::printData, '<', _1)); + client->onDataWritten.connect(boost::bind(&ComponentXMLTracer::printData, '>', _1)); +} + +void ComponentXMLTracer::printData(char direction, const SafeByteArray& data) { + printLine(direction); + std::cerr << byteArrayToString(ByteArray(data.begin(), data.end())) << std::endl; +} + +void ComponentXMLTracer::printLine(char c) { + for (unsigned int i = 0; i < 80; ++i) { + std::cerr << c; + } + std::cerr << std::endl; +} + +} diff --git a/Swiften/Component/ComponentXMLTracer.h b/Swiften/Component/ComponentXMLTracer.h index 70a617b..c12ec07 100644 --- a/Swiften/Component/ComponentXMLTracer.h +++ b/Swiften/Component/ComponentXMLTracer.h @@ -6,29 +6,15 @@ #pragma once -#include <boost/bind.hpp> - -#include "Swiften/Component/Component.h" +#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)); - } + ComponentXMLTracer(CoreComponent* component); private: - static void printData(char direction, const std::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; - } + static void printData(char direction, const SafeByteArray& data); + static void printLine(char c); }; } diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp index e79d735..7ee1ff5 100644 --- a/Swiften/Component/CoreComponent.cpp +++ b/Swiften/Component/CoreComponent.cpp @@ -4,18 +4,19 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swiften/Component/CoreComponent.h" +#include <Swiften/Component/CoreComponent.h> #include <boost/bind.hpp> +#include <iostream> -#include "Swiften/Component/ComponentSession.h" -#include "Swiften/Network/Connector.h" -#include "Swiften/Network/NetworkFactories.h" -#include "Swiften/TLS/PKCS12Certificate.h" -#include "Swiften/Session/BasicSessionStream.h" -#include "Swiften/Queries/IQRouter.h" -#include "Swiften/Base/IDGenerator.h" -#include "Swiften/Component/ComponentSessionStanzaChannel.h" +#include <Swiften/Component/ComponentSession.h> +#include <Swiften/Network/Connector.h> +#include <Swiften/Network/NetworkFactories.h> +#include <Swiften/TLS/PKCS12Certificate.h> +#include <Swiften/Session/BasicSessionStream.h> +#include <Swiften/Queries/IQRouter.h> +#include <Swiften/Base/IDGenerator.h> +#include <Swiften/Component/ComponentSessionStanzaChannel.h> namespace Swift { @@ -138,11 +139,11 @@ void CoreComponent::handleSessionFinished(boost::shared_ptr<Error> error) { } } -void CoreComponent::handleDataRead(const std::string& data) { +void CoreComponent::handleDataRead(const SafeByteArray& data) { onDataRead(data); } -void CoreComponent::handleDataWritten(const std::string& data) { +void CoreComponent::handleDataWritten(const SafeByteArray& data) { onDataWritten(data); } diff --git a/Swiften/Component/CoreComponent.h b/Swiften/Component/CoreComponent.h index 64c9071..e7945d1 100644 --- a/Swiften/Component/CoreComponent.h +++ b/Swiften/Component/CoreComponent.h @@ -8,20 +8,21 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/Error.h" -#include "Swiften/Network/PlatformDomainNameResolver.h" -#include "Swiften/Component/ComponentConnector.h" -#include "Swiften/Component/ComponentSession.h" -#include "Swiften/Component/ComponentError.h" -#include "Swiften/Elements/Presence.h" -#include "Swiften/Elements/Message.h" -#include "Swiften/JID/JID.h" +#include <Swiften/Base/boost_bsignals.h> +#include <Swiften/Base/Error.h> +#include <Swiften/Network/PlatformDomainNameResolver.h> +#include <Swiften/Component/ComponentConnector.h> +#include <Swiften/Component/ComponentSession.h> +#include <Swiften/Component/ComponentError.h> +#include <Swiften/Elements/Presence.h> +#include <Swiften/Elements/Message.h> +#include <Swiften/JID/JID.h> #include <string> -#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" -#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" -#include "Swiften/Component/ComponentSessionStanzaChannel.h" +#include <Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h> +#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> +#include <Swiften/Component/ComponentSessionStanzaChannel.h> #include <Swiften/Entity/Entity.h> +#include <Swiften/Base/SafeByteArray.h> namespace Swift { class IQRouter; @@ -72,8 +73,8 @@ namespace Swift { public: boost::signal<void (const ComponentError&)> onError; boost::signal<void ()> onConnected; - boost::signal<void (const std::string&)> onDataRead; - boost::signal<void (const std::string&)> onDataWritten; + boost::signal<void (const SafeByteArray&)> onDataRead; + boost::signal<void (const SafeByteArray&)> onDataWritten; boost::signal<void (boost::shared_ptr<Message>)> onMessageReceived; boost::signal<void (boost::shared_ptr<Presence>) > onPresenceReceived; @@ -82,8 +83,8 @@ namespace Swift { void handleConnectorFinished(boost::shared_ptr<Connection>); void handleStanzaChannelAvailableChanged(bool available); void handleSessionFinished(boost::shared_ptr<Error>); - void handleDataRead(const std::string&); - void handleDataWritten(const std::string&); + void handleDataRead(const SafeByteArray&); + void handleDataWritten(const SafeByteArray&); private: EventLoop* eventLoop; diff --git a/Swiften/Component/SConscript b/Swiften/Component/SConscript index 0a9f250..ef5700c 100644 --- a/Swiften/Component/SConscript +++ b/Swiften/Component/SConscript @@ -7,6 +7,7 @@ sources = [ "ComponentSessionStanzaChannel.cpp", "CoreComponent.cpp", "Component.cpp", + "ComponentXMLTracer.cpp", ] swiften_env.Append(SWIFTEN_OBJECTS = swiften_env.SwiftenObject(sources)) diff --git a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp index 052b5de..1b2a36b 100644 --- a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp +++ b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp @@ -10,13 +10,13 @@ #include <boost/optional.hpp> #include <boost/bind.hpp> -#include "Swiften/Component/ComponentConnector.h" -#include "Swiften/Network/Connection.h" -#include "Swiften/Network/ConnectionFactory.h" -#include "Swiften/Network/HostAddressPort.h" -#include "Swiften/Network/StaticDomainNameResolver.h" -#include "Swiften/Network/DummyTimerFactory.h" -#include "Swiften/EventLoop/DummyEventLoop.h" +#include <Swiften/Component/ComponentConnector.h> +#include <Swiften/Network/Connection.h> +#include <Swiften/Network/ConnectionFactory.h> +#include <Swiften/Network/HostAddressPort.h> +#include <Swiften/Network/StaticDomainNameResolver.h> +#include <Swiften/Network/DummyTimerFactory.h> +#include <Swiften/EventLoop/DummyEventLoop.h> using namespace Swift; @@ -174,7 +174,7 @@ class ComponentConnectorTest : public CppUnit::TestFixture { } void disconnect() { assert(false); } - void write(const ByteArray&) { assert(false); } + void write(const SafeByteArray&) { assert(false); } HostAddressPort getLocalAddress() const { return HostAddressPort(); } EventLoop* eventLoop; diff --git a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp index 5366478..fd8f6fc 100644 --- a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp +++ b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp @@ -7,7 +7,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> -#include "Swiften/Component/ComponentHandshakeGenerator.h" +#include <Swiften/Component/ComponentHandshakeGenerator.h> using namespace Swift; diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp index 953973c..c27ade5 100644 --- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp +++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp @@ -10,10 +10,10 @@ #include <boost/bind.hpp> #include <boost/optional.hpp> -#include "Swiften/Session/SessionStream.h" -#include "Swiften/Component/ComponentSession.h" -#include "Swiften/Elements/ComponentHandshake.h" -#include "Swiften/Elements/AuthFailure.h" +#include <Swiften/Session/SessionStream.h> +#include <Swiften/Component/ComponentSession.h> +#include <Swiften/Elements/ComponentHandshake.h> +#include <Swiften/Elements/AuthFailure.h> using namespace Swift; @@ -187,7 +187,7 @@ class ComponentSessionTest : public CppUnit::TestFixture { } Event popEvent() { - CPPUNIT_ASSERT(receivedEvents.size() > 0); + CPPUNIT_ASSERT(!receivedEvents.empty()); Event event = receivedEvents.front(); receivedEvents.pop_front(); return event; |