summaryrefslogtreecommitdiff
path: root/src/bridge/bridge.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bridge/bridge.hpp')
-rw-r--r--src/bridge/bridge.hpp59
1 files changed, 53 insertions, 6 deletions
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index 69b7bd5..18ebfeb 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <bridge/result_set_management.hpp>
+#include <bridge/list_element.hpp>
#include <irc/irc_message.hpp>
#include <irc/irc_client.hpp>
@@ -13,8 +15,11 @@
#include <string>
#include <memory>
+#include <biboumi.h>
+
class BiboumiComponent;
class Poller;
+struct ResultSetInfo;
/**
* A callback called for each IrcMessage we receive. If the message triggers
@@ -45,6 +50,10 @@ public:
*/
void shutdown(const std::string& exit_message);
/**
+ * PART the given resource from all the channels
+ */
+ void remove_resource(const std::string& resource, const std::string& part_message);
+ /**
* Remove all inactive IrcClients
*/
void clean();
@@ -70,7 +79,7 @@ public:
void send_channel_message(const Iid& iid, const std::string& body);
void send_private_message(const Iid& iid, const std::string& body, const std::string& type="PRIVMSG");
void send_raw_message(const std::string& hostname, const std::string& body);
- void leave_irc_channel(Iid&& iid, std::string&& status_message, const std::string& resource);
+ void leave_irc_channel(Iid&& iid, const std::string& status_message, const std::string& resource);
void send_irc_nick_change(const Iid& iid, const std::string& new_nick);
void send_irc_kick(const Iid& iid, const std::string& target, const std::string& reason,
const std::string& iq_id, const std::string& to_jid);
@@ -81,8 +90,19 @@ public:
void send_irc_version_request(const std::string& irc_hostname, const std::string& target,
const std::string& iq_id, const std::string& to_jid,
const std::string& from_jid);
- void send_irc_channel_list_request(const Iid& iid, const std::string& iq_id,
- const std::string& to_jid);
+ void send_irc_channel_list_request(const Iid& iid, const std::string& iq_id, const std::string& to_jid,
+ ResultSetInfo rs_info);
+ /**
+ * Check if the channel list contains what is needed to answer the RSM request,
+ * if it does, send the iq result. If the list is complete but does not contain
+ * everything, send the result anyway (because there are no more available
+ * channels that could complete the list).
+ *
+ * Returns true if we sent the answer.
+ */
+ bool send_matching_channel_list(const ChannelList& channel_list,
+ const ResultSetInfo& rs_info, const std::string& id, const std::string& to_jid,
+ const std::string& from);
void forward_affiliation_role_change(const Iid& iid, const std::string& nick,
const std::string& affiliation, const std::string& role);
/**
@@ -105,6 +125,8 @@ public:
void on_gateway_ping(const std::string& irc_hostname, const std::string& iq_id, const std::string& to_jid,
const std::string& from_jid);
+ void send_irc_invitation(const Iid& iid, const std::string& to);
+
/***
**
** From IRC to XMPP.
@@ -132,6 +154,11 @@ public:
void send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic, const std::string& who);
void send_topic(const std::string& hostname, const std::string& chan_name, const std::string& topic, const std::string& who, const std::string& resource);
/**
+ * Send the MUC history to the user
+ */
+ void send_room_history(const std::string& hostname, const std::string& chan_name);
+ void send_room_history(const std::string& hostname, const std::string& chan_name, const std::string& resource);
+ /**
* Send a MUC message from some participant
*/
void send_message(const Iid& iid, const std::string& nick, const std::string& body, const bool muc);
@@ -154,7 +181,8 @@ public:
const std::string& new_nick,
const char user_mode,
const bool self);
- void kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author);
+ void kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author,
+ const bool self);
void send_nickname_conflict_error(const Iid& iid, const std::string& nickname);
/**
* Send a role/affiliation change, matching the change of mode for that user
@@ -169,6 +197,8 @@ public:
*/
void send_xmpp_ping_request(const std::string& nick, const std::string& hostname,
const std::string& id);
+ void send_xmpp_invitation(const Iid& iid, const std::string& author);
+
/**
* Misc
*/
@@ -201,6 +231,10 @@ public:
*/
void trigger_on_irc_message(const std::string& irc_hostname, const IrcMessage& message);
std::unordered_map<std::string, std::shared_ptr<IrcClient>>& get_irc_clients();
+ std::set<char> get_chantypes(const std::string& hostname) const;
+#ifdef USE_DATABASE
+ void set_record_history(const bool val);
+#endif
private:
/**
@@ -214,10 +248,12 @@ private:
* a IRCServerNotConnected error in that case.
*/
IrcClient* get_irc_client(const std::string& hostname);
+public:
/**
* Idem, but returns nullptr if the server does not exist.
*/
- IrcClient* find_irc_client(const std::string& hostname);
+ IrcClient* find_irc_client(const std::string& hostname) const;
+private:
/**
* The bare JID of the user associated with this bridge. Messages from/to this
* JID are only managed by this bridge.
@@ -252,7 +288,6 @@ private:
* response iq.
*/
std::vector<irc_responder_callback_t> waiting_irc;
-
/**
* Resources to IRC channel/server mapping:
*/
@@ -260,7 +295,9 @@ private:
using ChannelName = std::string;
using IrcHostname = std::string;
using ChannelKey = std::tuple<ChannelName, IrcHostname>;
+public:
std::map<ChannelKey, std::set<Resource>> resources_in_chan;
+private:
std::map<IrcHostname, std::set<Resource>> resources_in_server;
/**
* Manage which resource is in which channel
@@ -281,6 +318,16 @@ private:
* TODO: send message history
*/
void generate_channel_join_for_resource(const Iid& iid, const std::string& resource);
+ /**
+ * A cache of the channels list (as returned by the server on a LIST
+ * request), to be re-used on a subsequent XMPP list request that
+ * uses result-set-management.
+ */
+ std::map<IrcHostname, ChannelList> channel_list_cache;
+
+#ifdef USE_DATABASE
+ bool record_history { true };
+#endif
};
struct IRCNotConnected: public std::exception