summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-06-03 11:09:08 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-06-03 11:09:08 (GMT)
commit10334c139670861d4860da59ad837fc3fe6fd41e (patch)
treeb632360747e635e229f336760ccc76789797a8bf /Swiften/Component
parent8189054fca9c68194ffc328eb7beecf241bbbcd7 (diff)
downloadswift-10334c139670861d4860da59ad837fc3fe6fd41e.zip
swift-10334c139670861d4860da59ad837fc3fe6fd41e.tar.bz2
Ensure safety on onDataRead and onDataWritten signals.
Diffstat (limited to 'Swiften/Component')
-rw-r--r--Swiften/Component/ComponentXMLTracer.cpp4
-rw-r--r--Swiften/Component/ComponentXMLTracer.h2
-rw-r--r--Swiften/Component/CoreComponent.cpp4
-rw-r--r--Swiften/Component/CoreComponent.h9
4 files changed, 10 insertions, 9 deletions
diff --git a/Swiften/Component/ComponentXMLTracer.cpp b/Swiften/Component/ComponentXMLTracer.cpp
index b952c29..d77eef7 100644
--- a/Swiften/Component/ComponentXMLTracer.cpp
+++ b/Swiften/Component/ComponentXMLTracer.cpp
@@ -16,9 +16,9 @@ ComponentXMLTracer::ComponentXMLTracer(CoreComponent* client) {
client->onDataWritten.connect(boost::bind(&ComponentXMLTracer::printData, '>', _1));
}
-void ComponentXMLTracer::printData(char direction, const std::string& data) {
+void ComponentXMLTracer::printData(char direction, const SafeByteArray& data) {
printLine(direction);
- std::cerr << data << std::endl;
+ std::cerr << byteArrayToString(ByteArray(data.begin(), data.end())) << std::endl;
}
void ComponentXMLTracer::printLine(char c) {
diff --git a/Swiften/Component/ComponentXMLTracer.h b/Swiften/Component/ComponentXMLTracer.h
index 2db690f..c12ec07 100644
--- a/Swiften/Component/ComponentXMLTracer.h
+++ b/Swiften/Component/ComponentXMLTracer.h
@@ -14,7 +14,7 @@ namespace Swift {
ComponentXMLTracer(CoreComponent* component);
private:
- static void printData(char direction, const std::string& data);
+ 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 7f02768..7ee1ff5 100644
--- a/Swiften/Component/CoreComponent.cpp
+++ b/Swiften/Component/CoreComponent.cpp
@@ -139,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 26f0024..e7945d1 100644
--- a/Swiften/Component/CoreComponent.h
+++ b/Swiften/Component/CoreComponent.h
@@ -22,6 +22,7 @@
#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;