summaryrefslogtreecommitdiff
path: root/src/xmpp/xmpp_component.hpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-06 20:51:05 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-06 21:01:18 +0100
commitbf7b05ef72bbdac97704d262ddfe418908267535 (patch)
treeb23b3a5a5d469c47c37422559be76ee34238649a /src/xmpp/xmpp_component.hpp
parentdea7f60fa1ae6a46228daa36bcb3fec1a6c6ffc3 (diff)
downloadbiboumi-bf7b05ef72bbdac97704d262ddfe418908267535.tar.gz
biboumi-bf7b05ef72bbdac97704d262ddfe418908267535.tar.bz2
biboumi-bf7b05ef72bbdac97704d262ddfe418908267535.tar.xz
biboumi-bf7b05ef72bbdac97704d262ddfe418908267535.zip
Implement the Bridge class to translate between the two protocols
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.
Diffstat (limited to 'src/xmpp/xmpp_component.hpp')
-rw-r--r--src/xmpp/xmpp_component.hpp36
1 files changed, 32 insertions, 4 deletions
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 <string>
-
#include <network/socket_handler.hpp>
-
#include <xmpp/xmpp_parser.hpp>
+#include <bridge/bridge.hpp>
#include <unordered_map>
+#include <memory>
+#include <string>
/**
* 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<std::string, std::function<void(const Stanza&)>> stanza_handlers;
+ /**
+ * One bridge for each user of the component. Indexed by the user's full
+ * jid
+ */
+ std::unordered_map<std::string, std::unique_ptr<Bridge>> bridges;
+
XmppComponent(const XmppComponent&) = delete;
XmppComponent(XmppComponent&&) = delete;
XmppComponent& operator=(const XmppComponent&) = delete;