From d600a2843f1dbe3b1ba2dead9a020cc73d7d10ae Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Fri, 27 Feb 2015 12:16:09 +0100 Subject: Remove all the libs that are now in louloulibs --- src/xmpp/biboumi_component.hpp | 111 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/xmpp/biboumi_component.hpp (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp new file mode 100644 index 0000000..e9b5d72 --- /dev/null +++ b/src/xmpp/biboumi_component.hpp @@ -0,0 +1,111 @@ +#ifndef BIBOUMI_COMPONENT_INCLUDED +# define BIBOUMI_COMPONENT_INCLUDED + +#include + +#include + +#include +#include +#include + +class ListElement; + +/** + * A callback called when the waited iq result is received (it is matched + * against the iq id) + */ +using iq_responder_callback_t = std::function; + +/** + * Interact with the Biboumi Bridge + */ +class BiboumiComponent: public XmppComponent +{ +public: + explicit BiboumiComponent(std::shared_ptr poller, const std::string& hostname, const std::string& secret); + ~BiboumiComponent() = default; + + /** + * Returns the bridge for the given user. If it does not exist, return + * nullptr. + */ + Bridge* find_user_bridge(const std::string& user_jid); + /** + * Return a list of all the managed bridges. + */ + std::list get_bridges() const; + + /** + * Send a "close" message to all our connected peers. That message + * depends on the protocol used (this may be a QUIT irc message, or a + * , etc). We may also directly close the connection, or we may + * wait for the remote peer to acknowledge it before closing. + */ + void shutdown(); + /** + * Run a check on all bridges, to remove all disconnected (socket is + * closed, or no channel is joined) IrcClients. Some kind of garbage collector. + */ + void clean(); + /** + * Send a result IQ with the gateway disco informations. + */ + void send_self_disco_info(const std::string& id, const std::string& jid_to); + /** + * Send the list of all available ad-hoc commands to that JID. The list is + * different depending on what JID made the request. + */ + void send_adhoc_commands_list(const std::string& id, const std::string& requester_jid); + /** + * Send an iq version request + */ + void send_iq_version_request(const std::string& from, + const std::string& jid_to); + /** + * Send a ping request + */ + void send_ping_request(const std::string& from, + const std::string& jid_to, + const std::string& id); + /** + * Send the channels list in one big stanza + */ + void send_iq_room_list_result(const std::string& id, const std::string to_jid, + const std::string& from, + const std::vector& rooms_list); + /** + * Handle the various stanza types + */ + void handle_presence(const Stanza& stanza); + void handle_message(const Stanza& stanza); + void handle_iq(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); + + /** + * A map of id -> callback. When we want to wait for an iq result, we add + * the callback to this map, with the iq id as the key. When an iq result + * is received, we look for a corresponding callback in this map. If + * found, we call it and remove it. + */ + std::map waiting_iq; + + /** + * One bridge for each user of the component. Indexed by the user's full + * jid + */ + std::unordered_map> bridges; + + BiboumiComponent(const BiboumiComponent&) = delete; + BiboumiComponent(BiboumiComponent&&) = delete; + BiboumiComponent& operator=(const BiboumiComponent&) = delete; + BiboumiComponent& operator=(BiboumiComponent&&) = delete; +}; + +#endif // BIBOUMI_COMPONENT_INCLUDED -- cgit v1.2.3 From 8da03f98307e03a767cb68659c8473c896cbd325 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 9 Jun 2015 14:51:55 +0200 Subject: Remove a useless duplicate method --- src/xmpp/biboumi_component.hpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index e9b5d72..8b0b3da 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -52,11 +52,6 @@ public: * Send a result IQ with the gateway disco informations. */ void send_self_disco_info(const std::string& id, const std::string& jid_to); - /** - * Send the list of all available ad-hoc commands to that JID. The list is - * different depending on what JID made the request. - */ - void send_adhoc_commands_list(const std::string& id, const std::string& requester_jid); /** * Send an iq version request */ -- cgit v1.2.3 From 45e8fe56a688ec03201cdfc3dfea6ae186af682d Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Fri, 18 Sep 2015 21:55:21 +0200 Subject: Add an AdhocCommandsHandler to store commands specific to IRC servers --- src/xmpp/biboumi_component.hpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 8b0b3da..fe99f2d 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -97,6 +97,8 @@ private: */ std::unordered_map> bridges; + AdhocCommandsHandler irc_server_adhoc_commands_handler; + BiboumiComponent(const BiboumiComponent&) = delete; BiboumiComponent(BiboumiComponent&&) = delete; BiboumiComponent& operator=(const BiboumiComponent&) = delete; -- cgit v1.2.3 From f6d9b7d7a1d670b3b3d2bd1ca831de8578de6206 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 22 Sep 2015 04:01:09 +0200 Subject: Fix two small warnings --- src/xmpp/biboumi_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index fe99f2d..b8fca39 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -9,7 +9,7 @@ #include #include -class ListElement; +struct ListElement; /** * A callback called when the waited iq result is received (it is matched -- cgit v1.2.3 From 142516a69bb000ce80cbb6509d1f407438a94663 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 26 Oct 2015 20:09:39 +0100 Subject: Fix some trivial issues reported by cppcheck --- src/xmpp/biboumi_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index b8fca39..69eebdc 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -66,7 +66,7 @@ public: /** * Send the channels list in one big stanza */ - void send_iq_room_list_result(const std::string& id, const std::string to_jid, + void send_iq_room_list_result(const std::string& id, const std::string& to_jid, const std::string& from, const std::vector& rooms_list); /** -- cgit v1.2.3 From 1fc3fa1bd8d98d45d18e8af76202cbf6b757b369 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 24 Dec 2015 15:50:29 +0100 Subject: Add an ad-hoc configure command on IRC channels Include encodingIn and encodingOut options, unused at the moment --- src/xmpp/biboumi_component.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 69eebdc..7602332 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -98,6 +98,7 @@ private: std::unordered_map> bridges; AdhocCommandsHandler irc_server_adhoc_commands_handler; + AdhocCommandsHandler irc_channel_adhoc_commands_handler; BiboumiComponent(const BiboumiComponent&) = delete; BiboumiComponent(BiboumiComponent&&) = delete; -- cgit v1.2.3 From af42073830087d97385e507f27f601e8769541b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 4 May 2016 14:16:40 +0200 Subject: Style fix Move all constructors at the top of classes --- src/xmpp/biboumi_component.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 7602332..f1817e2 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -26,6 +26,11 @@ public: explicit BiboumiComponent(std::shared_ptr poller, const std::string& hostname, const std::string& secret); ~BiboumiComponent() = default; + BiboumiComponent(const BiboumiComponent&) = delete; + BiboumiComponent(BiboumiComponent&&) = delete; + BiboumiComponent& operator=(const BiboumiComponent&) = delete; + BiboumiComponent& operator=(BiboumiComponent&&) = delete; + /** * Returns the bridge for the given user. If it does not exist, return * nullptr. @@ -99,11 +104,6 @@ private: AdhocCommandsHandler irc_server_adhoc_commands_handler; AdhocCommandsHandler irc_channel_adhoc_commands_handler; - - BiboumiComponent(const BiboumiComponent&) = delete; - BiboumiComponent(BiboumiComponent&&) = delete; - BiboumiComponent& operator=(const BiboumiComponent&) = delete; - BiboumiComponent& operator=(BiboumiComponent&&) = delete; }; #endif // BIBOUMI_COMPONENT_INCLUDED -- cgit v1.2.3 From 367de4826c3c7298a88e80c92e325081a3c3d794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 18 May 2016 22:53:17 +0200 Subject: Associate a bridge with a bare JID instead of a full JID ref #2556 --- src/xmpp/biboumi_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index f1817e2..4d5995e 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -83,7 +83,7 @@ public: private: /** - * Return the bridge associated with the given full JID. Create a new one + * Return the bridge associated with the bare JID. Create a new one * if none already exist. */ Bridge* get_user_bridge(const std::string& user_jid); -- cgit v1.2.3 From 711861d40e365564e3828a251066c16e924d30f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 22 May 2016 12:54:18 +0200 Subject: Add methods to know which resource is on which server or channel --- src/xmpp/biboumi_component.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 4d5995e..25982f2 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -35,7 +35,7 @@ public: * Returns the bridge for the given user. If it does not exist, return * nullptr. */ - Bridge* find_user_bridge(const std::string& user_jid); + Bridge* find_user_bridge(const std::string& full_jid); /** * Return a list of all the managed bridges. */ @@ -97,7 +97,7 @@ private: std::map waiting_iq; /** - * One bridge for each user of the component. Indexed by the user's full + * One bridge for each user of the component. Indexed by the user's bare * jid */ std::unordered_map> bridges; -- cgit v1.2.3 From 66609cfba2b581be52de6096193751d1bb4ec3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 22 May 2016 12:52:05 +0200 Subject: Remove all usage of std::list --- src/xmpp/biboumi_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 25982f2..0eb3bc4 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -39,7 +39,7 @@ public: /** * Return a list of all the managed bridges. */ - std::list get_bridges() const; + std::vector get_bridges() const; /** * Send a "close" message to all our connected peers. That message -- cgit v1.2.3 From 81f8f45b371d1a0ef72c2768fbd1f9188fe83616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 4 Jul 2016 17:53:53 +0200 Subject: Replace all include guards by #pragma once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s $CURRENT_YEAR --- src/xmpp/biboumi_component.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/xmpp/biboumi_component.hpp') diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 0eb3bc4..24d768a 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -1,5 +1,5 @@ -#ifndef BIBOUMI_COMPONENT_INCLUDED -# define BIBOUMI_COMPONENT_INCLUDED +#pragma once + #include @@ -106,4 +106,4 @@ private: AdhocCommandsHandler irc_channel_adhoc_commands_handler; }; -#endif // BIBOUMI_COMPONENT_INCLUDED + -- cgit v1.2.3