diff options
Diffstat (limited to 'Swiften')
24 files changed, 39 insertions, 40 deletions
diff --git a/Swiften/Disco/CapsManager.cpp b/Swiften/Disco/CapsManager.cpp index 43c2805..1c785e5 100644 --- a/Swiften/Disco/CapsManager.cpp +++ b/Swiften/Disco/CapsManager.cpp @@ -48,7 +48,7 @@ void CapsManager::handleStanzaChannelAvailableChanged(bool available) { } } -void CapsManager::handleDiscoInfoReceived(const JID& from, const String& hash, DiscoInfo::ref discoInfo, const boost::optional<ErrorPayload>& error) { +void CapsManager::handleDiscoInfoReceived(const JID& from, const String& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) { requestedDiscoInfos.erase(hash); if (error || CapsInfoGenerator("").generateCapsInfo(*discoInfo.get()).getVersion() != hash) { if (warnOnInvalidHash && !error) { diff --git a/Swiften/Disco/CapsManager.h b/Swiften/Disco/CapsManager.h index cbe3a44..842f2be 100644 --- a/Swiften/Disco/CapsManager.h +++ b/Swiften/Disco/CapsManager.h @@ -36,7 +36,7 @@ namespace Swift { private: void handlePresenceReceived(boost::shared_ptr<Presence>); void handleStanzaChannelAvailableChanged(bool); - void handleDiscoInfoReceived(const JID&, const String& hash, DiscoInfo::ref, const boost::optional<ErrorPayload>&); + void handleDiscoInfoReceived(const JID&, const String& hash, DiscoInfo::ref, ErrorPayload::ref); void requestDiscoInfo(const JID& jid, const String& node, const String& hash); private: diff --git a/Swiften/Elements/ErrorPayload.h b/Swiften/Elements/ErrorPayload.h index 9f00d53..8f849f2 100644 --- a/Swiften/Elements/ErrorPayload.h +++ b/Swiften/Elements/ErrorPayload.h @@ -6,12 +6,16 @@ #pragma once +#include <boost/shared_ptr.hpp> + #include "Swiften/Elements/Payload.h" #include "Swiften/Base/String.h" namespace Swift { class ErrorPayload : public Payload { public: + typedef boost::shared_ptr<ErrorPayload> ref; + enum Type { Cancel, Continue, Modify, Auth, Wait }; enum Condition { @@ -41,10 +45,6 @@ namespace Swift { ErrorPayload(Condition condition = UndefinedCondition, Type type = Cancel, const String& text = String()) : type_(type), condition_(condition), text_(text) { } - ErrorPayload(const ErrorPayload& other) : Payload(), type_(other.getType()), condition_(other.getCondition()), text_(other.getText()) { - - } - Type getType() const { return type_; } diff --git a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp index c090153..578cab5 100644 --- a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp +++ b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp @@ -28,7 +28,7 @@ JID recipient; int exitCode = CANNOT_CONNECT; boost::bsignals::connection errorConnection; -void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> /*info*/, const boost::optional<ErrorPayload>& error) { +void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> /*info*/, ErrorPayload::ref error) { if (!error) { errorConnection.disconnect(); client->disconnect(); diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp index 7246187..30f8836 100644 --- a/Swiften/FileTransfer/IBBSendSession.cpp +++ b/Swiften/FileTransfer/IBBSendSession.cpp @@ -34,7 +34,7 @@ void IBBSendSession::stop() { finish(boost::optional<FileTransferError>()); } -void IBBSendSession::handleIBBResponse(IBB::ref, const boost::optional<ErrorPayload>& error) { +void IBBSendSession::handleIBBResponse(IBB::ref, ErrorPayload::ref error) { if (!error) { if (!bytestream->isFinished()) { try { diff --git a/Swiften/FileTransfer/IBBSendSession.h b/Swiften/FileTransfer/IBBSendSession.h index 102bae2..e114b23 100644 --- a/Swiften/FileTransfer/IBBSendSession.h +++ b/Swiften/FileTransfer/IBBSendSession.h @@ -34,7 +34,7 @@ namespace Swift { boost::signal<void (boost::optional<FileTransferError>)> onFinished; private: - void handleIBBResponse(IBB::ref, const boost::optional<ErrorPayload>&); + void handleIBBResponse(IBB::ref, ErrorPayload::ref); void finish(boost::optional<FileTransferError>); private: diff --git a/Swiften/FileTransfer/OutgoingFileTransfer.cpp b/Swiften/FileTransfer/OutgoingFileTransfer.cpp index 9f1dd1b..4fa8d94 100644 --- a/Swiften/FileTransfer/OutgoingFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingFileTransfer.cpp @@ -32,7 +32,7 @@ void OutgoingFileTransfer::start() { void OutgoingFileTransfer::stop() { } -void OutgoingFileTransfer::handleStreamInitiationRequestResponse(StreamInitiation::ref response, const boost::optional<ErrorPayload>& error) { +void OutgoingFileTransfer::handleStreamInitiationRequestResponse(StreamInitiation::ref response, ErrorPayload::ref error) { if (error) { finish(FileTransferError()); } @@ -55,7 +55,7 @@ void OutgoingFileTransfer::handleStreamInitiationRequestResponse(StreamInitiatio } } -void OutgoingFileTransfer::handleBytestreamsRequestResponse(Bytestreams::ref, const boost::optional<ErrorPayload>& error) { +void OutgoingFileTransfer::handleBytestreamsRequestResponse(Bytestreams::ref, ErrorPayload::ref error) { if (error) { finish(FileTransferError()); } diff --git a/Swiften/FileTransfer/OutgoingFileTransfer.h b/Swiften/FileTransfer/OutgoingFileTransfer.h index cfbfe21..3ecef5d 100644 --- a/Swiften/FileTransfer/OutgoingFileTransfer.h +++ b/Swiften/FileTransfer/OutgoingFileTransfer.h @@ -32,8 +32,8 @@ namespace Swift { boost::signal<void (const boost::optional<FileTransferError>&)> onFinished; private: - void handleStreamInitiationRequestResponse(StreamInitiation::ref, const boost::optional<ErrorPayload>&); - void handleBytestreamsRequestResponse(Bytestreams::ref, const boost::optional<ErrorPayload>&); + void handleStreamInitiationRequestResponse(StreamInitiation::ref, ErrorPayload::ref); + void handleBytestreamsRequestResponse(Bytestreams::ref, ErrorPayload::ref); void finish(boost::optional<FileTransferError> error); void handleIBBSessionFinished(boost::optional<FileTransferError> error); diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index 86c8ca9..4185fa8 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -175,10 +175,9 @@ void MUC::handleIncomingPresence(boost::shared_ptr<Presence> presence) { } -void MUC::handleCreationConfigResponse(boost::shared_ptr<MUCOwnerPayload> /*unused*/, const boost::optional<ErrorPayload>& error) { +void MUC::handleCreationConfigResponse(boost::shared_ptr<MUCOwnerPayload> /*unused*/, ErrorPayload::ref error) { if (error) { - boost::shared_ptr<ErrorPayload> errorCopy(new ErrorPayload(*error)); - onJoinFailed(errorCopy); + onJoinFailed(error); } else { /* onJoinComplete(getOwnNick()); isn't needed here, the presence will cause an emit elsewhere. */ presenceSender->addDirectedPresenceReceiver(ownMUCJID); diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h index 3539e49..56cd392 100644 --- a/Swiften/MUC/MUC.h +++ b/Swiften/MUC/MUC.h @@ -76,7 +76,7 @@ namespace Swift { private: void handleIncomingPresence(boost::shared_ptr<Presence> presence); void internalJoin(const String& nick); - void handleCreationConfigResponse(boost::shared_ptr<MUCOwnerPayload>, const boost::optional<ErrorPayload>&); + void handleCreationConfigResponse(boost::shared_ptr<MUCOwnerPayload>, ErrorPayload::ref); private: JID ownMUCJID; diff --git a/Swiften/MUC/MUCBookmarkManager.cpp b/Swiften/MUC/MUCBookmarkManager.cpp index 0f5f3bb..d0855cd 100644 --- a/Swiften/MUC/MUCBookmarkManager.cpp +++ b/Swiften/MUC/MUCBookmarkManager.cpp @@ -24,7 +24,7 @@ MUCBookmarkManager::MUCBookmarkManager(IQRouter* iqRouter) { request->send(); } -void MUCBookmarkManager::handleBookmarksReceived(boost::shared_ptr<Storage> payload, const boost::optional<ErrorPayload>& error) { +void MUCBookmarkManager::handleBookmarksReceived(boost::shared_ptr<Storage> payload, ErrorPayload::ref error) { if (error) { return; } diff --git a/Swiften/MUC/MUCBookmarkManager.h b/Swiften/MUC/MUCBookmarkManager.h index 35f5447..39699df 100644 --- a/Swiften/MUC/MUCBookmarkManager.h +++ b/Swiften/MUC/MUCBookmarkManager.h @@ -39,7 +39,7 @@ namespace Swift { private: bool containsEquivalent(const std::vector<MUCBookmark>& list, const MUCBookmark& bookmark); - void handleBookmarksReceived(boost::shared_ptr<Storage> payload, const boost::optional<ErrorPayload>& error); + void handleBookmarksReceived(boost::shared_ptr<Storage> payload, ErrorPayload::ref error); void flush(); private: diff --git a/Swiften/Queries/GenericRequest.h b/Swiften/Queries/GenericRequest.h index 72bbcbd..a8e3409 100644 --- a/Swiften/Queries/GenericRequest.h +++ b/Swiften/Queries/GenericRequest.h @@ -22,7 +22,7 @@ namespace Swift { Request(type, receiver, payload, router) { } - virtual void handleResponse(boost::shared_ptr<Payload> payload, boost::optional<ErrorPayload> error) { + virtual void handleResponse(boost::shared_ptr<Payload> payload, ErrorPayload::ref error) { onResponse(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(payload), error); } @@ -32,6 +32,6 @@ namespace Swift { } public: - boost::signal<void (boost::shared_ptr<PAYLOAD_TYPE>, const boost::optional<ErrorPayload>&)> onResponse; + boost::signal<void (boost::shared_ptr<PAYLOAD_TYPE>, ErrorPayload::ref)> onResponse; }; } diff --git a/Swiften/Queries/Request.cpp b/Swiften/Queries/Request.cpp index 45ece8a..35475c1 100644 --- a/Swiften/Queries/Request.cpp +++ b/Swiften/Queries/Request.cpp @@ -40,15 +40,15 @@ bool Request::handleIQ(boost::shared_ptr<IQ> iq) { bool handled = false; if (sent_ && iq->getID() == id_) { if (iq->getType() == IQ::Result) { - handleResponse(iq->getPayloadOfSameType(payload_), boost::optional<ErrorPayload>()); + handleResponse(iq->getPayloadOfSameType(payload_), ErrorPayload::ref()); } else { - boost::shared_ptr<ErrorPayload> errorPayload = iq->getPayload<ErrorPayload>(); + ErrorPayload::ref errorPayload = iq->getPayload<ErrorPayload>(); if (errorPayload) { - handleResponse(boost::shared_ptr<Payload>(), boost::optional<ErrorPayload>(*errorPayload)); + handleResponse(boost::shared_ptr<Payload>(), errorPayload); } else { - handleResponse(boost::shared_ptr<Payload>(), boost::optional<ErrorPayload>(ErrorPayload::UndefinedCondition)); + handleResponse(boost::shared_ptr<Payload>(), ErrorPayload::ref(new ErrorPayload(ErrorPayload::UndefinedCondition))); } } router_->removeHandler(this); diff --git a/Swiften/Queries/Request.h b/Swiften/Queries/Request.h index 9184dea..625c147 100644 --- a/Swiften/Queries/Request.h +++ b/Swiften/Queries/Request.h @@ -42,7 +42,7 @@ namespace Swift { return payload_; } - virtual void handleResponse(boost::shared_ptr<Payload>, boost::optional<ErrorPayload>) = 0; + virtual void handleResponse(boost::shared_ptr<Payload>, ErrorPayload::ref) = 0; private: bool handleIQ(boost::shared_ptr<IQ>); diff --git a/Swiften/Queries/Requests/GetPrivateStorageRequest.h b/Swiften/Queries/Requests/GetPrivateStorageRequest.h index b593495..f0b95d8 100644 --- a/Swiften/Queries/Requests/GetPrivateStorageRequest.h +++ b/Swiften/Queries/Requests/GetPrivateStorageRequest.h @@ -27,7 +27,7 @@ namespace Swift { GetPrivateStorageRequest(IQRouter* router) : Request(IQ::Get, JID(), boost::shared_ptr<PrivateStorage>(new PrivateStorage(boost::shared_ptr<Payload>(new PAYLOAD_TYPE()))), router) { } - virtual void handleResponse(boost::shared_ptr<Payload> payload, boost::optional<ErrorPayload> error) { + virtual void handleResponse(boost::shared_ptr<Payload> payload, ErrorPayload::ref error) { boost::shared_ptr<PrivateStorage> storage = boost::dynamic_pointer_cast<PrivateStorage>(payload); if (storage) { onResponse(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(storage->getPayload()), error); @@ -38,6 +38,6 @@ namespace Swift { } public: - boost::signal<void (boost::shared_ptr<PAYLOAD_TYPE>, const boost::optional<ErrorPayload>&)> onResponse; + boost::signal<void (boost::shared_ptr<PAYLOAD_TYPE>, ErrorPayload::ref)> onResponse; }; } diff --git a/Swiften/Queries/Requests/SetPrivateStorageRequest.h b/Swiften/Queries/Requests/SetPrivateStorageRequest.h index 1931f3a..69eb001 100644 --- a/Swiften/Queries/Requests/SetPrivateStorageRequest.h +++ b/Swiften/Queries/Requests/SetPrivateStorageRequest.h @@ -27,11 +27,11 @@ namespace Swift { SetPrivateStorageRequest(boost::shared_ptr<PAYLOAD_TYPE> payload, IQRouter* router) : Request(IQ::Set, JID(), boost::shared_ptr<PrivateStorage>(new PrivateStorage(payload)), router) { } - virtual void handleResponse(boost::shared_ptr<Payload>, boost::optional<ErrorPayload> error) { + virtual void handleResponse(boost::shared_ptr<Payload>, ErrorPayload::ref error) { onResponse(error); } public: - boost::signal<void (const boost::optional<ErrorPayload>&)> onResponse; + boost::signal<void (ErrorPayload::ref)> onResponse; }; } diff --git a/Swiften/Queries/Requests/SubmitInBandRegistrationFormRequest.h b/Swiften/Queries/Requests/SubmitInBandRegistrationFormRequest.h index fb2d344..0700c65 100644 --- a/Swiften/Queries/Requests/SubmitInBandRegistrationFormRequest.h +++ b/Swiften/Queries/Requests/SubmitInBandRegistrationFormRequest.h @@ -26,11 +26,11 @@ namespace Swift { SetInBandRegistrationRequest(const JID& to, InBandRegistrationPayload::ref payload, IQRouter* router) : Request(IQ::Set, to, InBandRegistrationPayload::ref(payload), router) { } - virtual void handleResponse(Payload::ref payload, boost::optional<ErrorPayload> error) { + virtual void handleResponse(Payload::ref payload, ErrorPayload::ref error) { onResponse(payload, error); } public: - boost::signal<void (Payload::ref, const boost::optional<ErrorPayload>&)> onResponse; + boost::signal<void (Payload::ref, ErrorPayload::ref)> onResponse; }; } diff --git a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp index fe8b0a0..89cd7f1 100644 --- a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp +++ b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp @@ -78,7 +78,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture } private: - void handleResponse(boost::shared_ptr<Payload> p, const boost::optional<ErrorPayload>& e) { + void handleResponse(boost::shared_ptr<Payload> p, ErrorPayload::ref e) { if (e) { errors.push_back(*e); } diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp index 0e0653b..3d8d6f2 100644 --- a/Swiften/Queries/UnitTest/RequestTest.cpp +++ b/Swiften/Queries/UnitTest/RequestTest.cpp @@ -136,7 +136,7 @@ class RequestTest : public CppUnit::TestFixture } private: - void handleResponse(boost::shared_ptr<Payload> p, const boost::optional<ErrorPayload>& e) { + void handleResponse(boost::shared_ptr<Payload> p, ErrorPayload::ref e) { if (e) { receivedErrors.push_back(*e); } diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp index aba2cb9..3a17729 100644 --- a/Swiften/Queries/UnitTest/ResponderTest.cpp +++ b/Swiften/Queries/UnitTest/ResponderTest.cpp @@ -131,13 +131,13 @@ class ResponderTest : public CppUnit::TestFixture public: MyResponder(IQRouter* router) : Responder<SoftwareVersion>(router), getRequestResponse_(true), setRequestResponse_(true) {} - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<SoftwareVersion> payload) { + virtual bool handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<SoftwareVersion> payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); CPPUNIT_ASSERT_EQUAL(String("myid"), id); getPayloads_.push_back(payload); return getRequestResponse_; } - virtual bool handleSetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<SoftwareVersion> payload) { + virtual bool handleSetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<SoftwareVersion> payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); CPPUNIT_ASSERT_EQUAL(String("myid"), id); setPayloads_.push_back(payload); diff --git a/Swiften/Roster/SetRosterRequest.h b/Swiften/Roster/SetRosterRequest.h index b1ecd1f..e5ae974 100644 --- a/Swiften/Roster/SetRosterRequest.h +++ b/Swiften/Roster/SetRosterRequest.h @@ -26,11 +26,11 @@ namespace Swift { SetRosterRequest(boost::shared_ptr<RosterPayload> payload, IQRouter* router) : Request(IQ::Set, JID(), boost::shared_ptr<RosterPayload>(payload), router) { } - virtual void handleResponse(boost::shared_ptr<Payload> /*payload*/, boost::optional<ErrorPayload> error) { + virtual void handleResponse(boost::shared_ptr<Payload> /*payload*/, ErrorPayload::ref error) { onResponse(error); } public: - boost::signal<void (const boost::optional<ErrorPayload>&)> onResponse; + boost::signal<void (ErrorPayload::ref)> onResponse; }; } diff --git a/Swiften/VCards/VCardManager.cpp b/Swiften/VCards/VCardManager.cpp index 5c26635..e0d3553 100644 --- a/Swiften/VCards/VCardManager.cpp +++ b/Swiften/VCards/VCardManager.cpp @@ -45,7 +45,7 @@ void VCardManager::requestOwnVCard() { } -void VCardManager::handleVCardReceived(const JID& actualJID, VCard::ref vcard, const boost::optional<ErrorPayload>& error) { +void VCardManager::handleVCardReceived(const JID& actualJID, VCard::ref vcard, ErrorPayload::ref error) { if (error) { vcard = VCard::ref(new VCard()); } diff --git a/Swiften/VCards/VCardManager.h b/Swiften/VCards/VCardManager.h index 67a2ef8..e1ed44a 100644 --- a/Swiften/VCards/VCardManager.h +++ b/Swiften/VCards/VCardManager.h @@ -34,7 +34,7 @@ namespace Swift { boost::signal<void (const JID&, VCard::ref)> onVCardChanged; private: - void handleVCardReceived(const JID& from, VCard::ref, const boost::optional<ErrorPayload>&); + void handleVCardReceived(const JID& from, VCard::ref, ErrorPayload::ref); private: JID ownJID; |