From bf7b05ef72bbdac97704d262ddfe418908267535 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 6 Nov 2013 20:51:05 +0100 Subject: Implement the Bridge class to translate between the two protocols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add all useful classes as well: Jid, Iid, IrcChannel, IrcUser etc to properly keep the informations about what we receive from the IRC server. Only handle the MUC join stanza, and send the list of users in the IRC channel to the XMPP user, and the IRC channel’s topic, for now. --- src/xmpp/xmpp_component.hpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/xmpp/xmpp_component.hpp') diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp index 464ecaa..725b495 100644 --- a/src/xmpp/xmpp_component.hpp +++ b/src/xmpp/xmpp_component.hpp @@ -1,13 +1,13 @@ #ifndef XMPP_COMPONENT_INCLUDED # define XMPP_COMPONENT_INCLUDED -#include - #include - #include +#include #include +#include +#include /** * An XMPP component, communicating with an XMPP server using the protocole @@ -55,13 +55,35 @@ public: * Send the closing signal for our document (not closing the connection though). */ void close_document(); - + /** + * Send a message from from@served_hostname, with the given body + */ + void send_message(const std::string& from, const std::string& body, const std::string& to); + /** + * Send a join from a new participant + */ + void send_user_join(const std::string& from, const std::string& nick, const std::string& to); + /** + * Send the self join to the user + */ + void send_self_join(const std::string& from, const std::string& nick, const std::string& to); + /** + * Send the MUC topic to the user + */ + void send_topic(const std::string& from, const std::string& topic, const std::string& to); /** * Handle the various stanza types */ void handle_handshake(const Stanza& stanza); + void handle_presence(const Stanza& stanza); private: + /** + * Return the bridge associated with the given full JID. Create a new one + * if none already exist. + */ + Bridge* get_user_bridge(const std::string& user_jid); + XmppParser parser; std::string stream_id; std::string served_hostname; @@ -70,6 +92,12 @@ private: std::unordered_map> stanza_handlers; + /** + * One bridge for each user of the component. Indexed by the user's full + * jid + */ + std::unordered_map> bridges; + XmppComponent(const XmppComponent&) = delete; XmppComponent(XmppComponent&&) = delete; XmppComponent& operator=(const XmppComponent&) = delete; -- cgit v1.2.3