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/irc/irc_channel.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/irc/irc_channel.hpp (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp new file mode 100644 index 0000000..da0f298 --- /dev/null +++ b/src/irc/irc_channel.hpp @@ -0,0 +1,34 @@ +#ifndef IRC_CHANNEL_INCLUDED +# define IRC_CHANNEL_INCLUDED + +#include +#include +#include +#include + +/** + * Keep the state of a joined channel (the list of occupants with their + * informations (mode, etc), the modes, etc) + */ +class IrcChannel +{ +public: + explicit IrcChannel(); + + bool joined; + std::string topic; + void set_self(const std::string& name); + IrcUser* get_self() const; + IrcUser* add_user(const std::string& name); + +private: + std::unique_ptr self; + std::vector> users; + + IrcChannel(const IrcChannel&) = delete; + IrcChannel(IrcChannel&&) = delete; + IrcChannel& operator=(const IrcChannel&) = delete; + IrcChannel& operator=(IrcChannel&&) = delete; +}; + +#endif // IRC_CHANNEL_INCLUDED -- cgit v1.2.3 From 7c671499350e22f8bfba2f72b9827aa5b200f7b0 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 9 Nov 2013 23:17:48 +0100 Subject: Implement part and join, both ways --- src/irc/irc_channel.hpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index da0f298..3786697 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -20,6 +20,8 @@ public: void set_self(const std::string& name); IrcUser* get_self() const; IrcUser* add_user(const std::string& name); + IrcUser* find_user(const std::string& name); + void remove_user(const IrcUser* user); private: std::unique_ptr self; -- cgit v1.2.3 From 5817a95b5ee89480788832be35679dfcd2ed833b Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 12 Nov 2013 23:43:43 +0100 Subject: Basic handling of modes, both ways --- src/irc/irc_channel.hpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 3786697..c4b6d2c 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -26,7 +26,6 @@ public: private: std::unique_ptr self; std::vector> users; - IrcChannel(const IrcChannel&) = delete; IrcChannel(IrcChannel&&) = delete; IrcChannel& operator=(const IrcChannel&) = delete; -- cgit v1.2.3 From acf769d83a40e971ccc1346225688841465b36ee Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 29 Dec 2013 19:57:43 +0100 Subject: Use isupport informations to know the user modes when joining Also remove the duplicate send_self_join methods, user only send_user_join --- src/irc/irc_channel.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index c4b6d2c..edb779a 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -5,6 +5,7 @@ #include #include #include +#include /** * Keep the state of a joined channel (the list of occupants with their @@ -19,7 +20,8 @@ public: std::string topic; void set_self(const std::string& name); IrcUser* get_self() const; - IrcUser* add_user(const std::string& name); + IrcUser* add_user(const std::string& name, + const std::map prefix_to_mode); IrcUser* find_user(const std::string& name); void remove_user(const IrcUser* user); -- cgit v1.2.3 From e840704b58a984351971e8034e74f5e9fdfaf114 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 4 Jan 2014 01:30:03 +0100 Subject: Convert received modes into roles and affiliations --- src/irc/irc_channel.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index edb779a..0160469 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -22,7 +22,7 @@ public: IrcUser* get_self() const; IrcUser* add_user(const std::string& name, const std::map prefix_to_mode); - IrcUser* find_user(const std::string& name); + IrcUser* find_user(const std::string& name) const; void remove_user(const IrcUser* user); private: -- cgit v1.2.3 From 020325dbb071f1735bceb80de9f982aefcd2de47 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 13 Apr 2014 15:37:56 +0200 Subject: [WIP] DummyIrcChannel --- src/irc/irc_channel.hpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 0160469..ab04d60 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -25,13 +25,44 @@ public: IrcUser* find_user(const std::string& name) const; void remove_user(const IrcUser* user); -private: +protected: std::unique_ptr self; std::vector> users; + +private: IrcChannel(const IrcChannel&) = delete; IrcChannel(IrcChannel&&) = delete; IrcChannel& operator=(const IrcChannel&) = delete; IrcChannel& operator=(IrcChannel&&) = delete; }; +/** + * A special channel that is not actually linked to any real irc + * channel. This is just a channel representing a connection to the + * server. If an user wants to maintain the connection to the server without + * having to be on any irc channel of that server, he can just join this + * dummy channel. + * It’s not actually dummy because it’s useful and it does things, but well. + */ +class DummyIrcChannel: public IrcChannel +{ +public: + explicit DummyIrcChannel(); + + /** + * This flag is at true whenever the user wants to join this channel, but + * he is not yet connected to the server. When the connection is made, we + * check that flag and if it’s true, we inform the user that he has just + * joined that channel. + * If the user is already connected to the server when he tries to join + * the channel, we don’t use that flag, we just join it immediately. + */ + bool joining; +private: + DummyIrcChannel(const DummyIrcChannel&) = delete; + DummyIrcChannel(DummyIrcChannel&&) = delete; + DummyIrcChannel& operator=(const DummyIrcChannel&) = delete; + DummyIrcChannel& operator=(DummyIrcChannel&&) = delete; +}; + #endif // IRC_CHANNEL_INCLUDED -- cgit v1.2.3 From 5739d418e2b35dfc038fe1a12f8b5c7eeeed6868 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 15 Apr 2014 04:56:50 +0200 Subject: Better way to leave the dummy room --- src/irc/irc_channel.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index ab04d60..1c074b5 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -24,6 +24,7 @@ public: const std::map prefix_to_mode); IrcUser* find_user(const std::string& name) const; void remove_user(const IrcUser* user); + void remove_all_users(); protected: std::unique_ptr self; -- cgit v1.2.3 From 720e31a5113c25e48d7754bb812ab84c6c31d1d9 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 17 Dec 2014 13:37:57 +0100 Subject: Fix a few issues reported by static analyzers --- src/irc/irc_channel.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 1c074b5..568de0a 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -21,7 +21,7 @@ public: void set_self(const std::string& name); IrcUser* get_self() const; IrcUser* add_user(const std::string& name, - const std::map prefix_to_mode); + const std::map& prefix_to_mode); IrcUser* find_user(const std::string& name) const; void remove_user(const IrcUser* user); void remove_all_users(); -- cgit v1.2.3 From 04d28f968b227067e77e365d317fc251d3c965f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 19 Apr 2016 02:43:26 +0200 Subject: Forward the topic authors, handle the author from 333 messages fix #2 --- src/irc/irc_channel.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 568de0a..651b8ed 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -18,6 +18,7 @@ public: bool joined; std::string topic; + std::string topic_author; void set_self(const std::string& name); IrcUser* get_self() const; IrcUser* add_user(const std::string& name, -- 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/irc/irc_channel.hpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 651b8ed..e22947b 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -16,6 +16,11 @@ class IrcChannel public: explicit IrcChannel(); + IrcChannel(const IrcChannel&) = delete; + IrcChannel(IrcChannel&&) = delete; + IrcChannel& operator=(const IrcChannel&) = delete; + IrcChannel& operator=(IrcChannel&&) = delete; + bool joined; std::string topic; std::string topic_author; @@ -30,12 +35,6 @@ public: protected: std::unique_ptr self; std::vector> users; - -private: - IrcChannel(const IrcChannel&) = delete; - IrcChannel(IrcChannel&&) = delete; - IrcChannel& operator=(const IrcChannel&) = delete; - IrcChannel& operator=(IrcChannel&&) = delete; }; /** @@ -50,6 +49,10 @@ class DummyIrcChannel: public IrcChannel { public: explicit DummyIrcChannel(); + DummyIrcChannel(const DummyIrcChannel&) = delete; + DummyIrcChannel(DummyIrcChannel&&) = delete; + DummyIrcChannel& operator=(const DummyIrcChannel&) = delete; + DummyIrcChannel& operator=(DummyIrcChannel&&) = delete; /** * This flag is at true whenever the user wants to join this channel, but @@ -60,11 +63,6 @@ public: * the channel, we don’t use that flag, we just join it immediately. */ bool joining; -private: - DummyIrcChannel(const DummyIrcChannel&) = delete; - DummyIrcChannel(DummyIrcChannel&&) = delete; - DummyIrcChannel& operator=(const DummyIrcChannel&) = delete; - DummyIrcChannel& operator=(DummyIrcChannel&&) = delete; }; #endif // IRC_CHANNEL_INCLUDED -- cgit v1.2.3 From 507d0c2cbe3c41e3d8e6d38862fe418cb551adf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 2 Jun 2016 01:35:15 +0200 Subject: Forward everything to all concerned XMPP resources --- src/irc/irc_channel.hpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index e22947b..3319505 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -31,6 +31,8 @@ public: IrcUser* find_user(const std::string& name) const; void remove_user(const IrcUser* user); void remove_all_users(); + const std::vector>& get_users() const + { return this->users; } protected: std::unique_ptr self; -- 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/irc/irc_channel.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/irc/irc_channel.hpp') diff --git a/src/irc/irc_channel.hpp b/src/irc/irc_channel.hpp index 3319505..2bcefaf 100644 --- a/src/irc/irc_channel.hpp +++ b/src/irc/irc_channel.hpp @@ -1,5 +1,5 @@ -#ifndef IRC_CHANNEL_INCLUDED -# define IRC_CHANNEL_INCLUDED +#pragma once + #include #include @@ -67,4 +67,4 @@ public: bool joining; }; -#endif // IRC_CHANNEL_INCLUDED + -- cgit v1.2.3