summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-01-04 01:53:50 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-01-04 01:59:36 +0100
commitfbec16f1a208881ea49923287aae27978d79681e (patch)
treeaaa68a23a507e7f26899132865f65816315ce882 /src
parente840704b58a984351971e8034e74f5e9fdfaf114 (diff)
downloadbiboumi-fbec16f1a208881ea49923287aae27978d79681e.tar.gz
biboumi-fbec16f1a208881ea49923287aae27978d79681e.tar.bz2
biboumi-fbec16f1a208881ea49923287aae27978d79681e.tar.xz
biboumi-fbec16f1a208881ea49923287aae27978d79681e.zip
Possibility to change a channel's topic
Diffstat (limited to 'src')
-rw-r--r--src/bridge/bridge.cpp7
-rw-r--r--src/bridge/bridge.hpp1
-rw-r--r--src/irc/irc_client.cpp5
-rw-r--r--src/irc/irc_client.hpp1
-rw-r--r--src/xmpp/xmpp_component.cpp3
5 files changed, 17 insertions, 0 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index d034bcd..dae5a72 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -156,6 +156,13 @@ void Bridge::send_irc_kick(const Iid& iid, const std::string& target, const std:
irc->send_kick_command(iid.chan, target, reason);
}
+void Bridge::set_channel_topic(const Iid& iid, const std::string& subject)
+{
+ IrcClient* irc = this->get_irc_client(iid.server);
+ if (irc)
+ irc->send_topic_command(iid.chan, subject);
+}
+
void Bridge::send_message(const Iid& iid, const std::string& nick, const std::string& body, const bool muc)
{
if (muc)
diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp
index 7e881d9..75708e5 100644
--- a/src/bridge/bridge.hpp
+++ b/src/bridge/bridge.hpp
@@ -49,6 +49,7 @@ public:
void leave_irc_channel(Iid&& iid, std::string&& status_message);
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);
+ void set_channel_topic(const Iid& iid, const std::string& subject);
/***
**
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 8a57371..644cfd1 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -122,6 +122,11 @@ void IrcClient::send_kick_command(const std::string& chan_name, const std::strin
this->send_message(IrcMessage("KICK", {chan_name, target, reason}));
}
+void IrcClient::send_topic_command(const std::string& chan_name, const std::string& topic)
+{
+ this->send_message(IrcMessage("TOPIC", {chan_name, topic}));
+}
+
void IrcClient::send_quit_command()
{
this->send_message(IrcMessage("QUIT", {"gateway shutdown"}));
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 96ded44..a058b19 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -97,6 +97,7 @@ public:
* Send the KICK irc command
*/
void send_kick_command(const std::string& chan_name, const std::string& target, const std::string& reason);
+ void send_topic_command(const std::string& chan_name, const std::string& topic);
/**
* Send the QUIT irc command
*/
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index a0054ea..b370daa 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -217,6 +217,9 @@ void XmppComponent::handle_message(const Stanza& stanza)
if (to.resource.empty())
if (body && !body->get_inner().empty())
bridge->send_channel_message(iid, body->get_inner());
+ XmlNode* subject = stanza.get_child(COMPONENT_NS":subject");
+ if (subject)
+ bridge->set_channel_topic(iid, subject->get_inner());
}
else
{