/* * 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 #include "Swiften/Base/IDGenerator.h" #include "Swiften/Server/ServerFromClientSession.h" #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Elements/Message.h" #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/Presence.h" #include "Swiften/TLS/Certificate.h" #include #define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000) namespace Swift { class Error; class ServerStanzaChannel : public StanzaChannel { public: ServerStanzaChannel(const JID &selfJID) : StanzaChannel() { m_jid = selfJID; } void addSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr session); void removeSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr session); void sendIQ(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr iq); void sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr message); void sendPresence(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr presence); #if HAVE_SWIFTEN_3 void finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr element, bool last = false); #else void finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr element, bool last = false); #endif bool getStreamManagementEnabled() const { return false; } bool isAvailable() const { return true; } std::vector getPeerCertificateChain() const { return std::vector(); } private: std::string getNewIQID(); void send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr stanza); void handleSessionFinished(const boost::optional&, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr &session); void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr element, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr &session); void handleDataRead(const SafeByteArray &data, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr &session); void handleSessionInitialized(); private: JID m_jid; IDGenerator idGenerator; // [JID][resources][ServerFromClientSession] std::map > > sessions; }; }