summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-01-14 13:48:34 +0100
committerFlorent Le Coz <louiz@louiz.org>2015-01-14 13:48:34 +0100
commit60569993b4532caffd8b1a6646292efbbd933585 (patch)
treeb7b5bfb6f0492a5731b2877f1726c2155d2a13cf
parentf9e259c266e5e9247562f899bafd5ddd2aa46099 (diff)
downloadbiboumi-60569993b4532caffd8b1a6646292efbbd933585.tar.gz
biboumi-60569993b4532caffd8b1a6646292efbbd933585.tar.bz2
biboumi-60569993b4532caffd8b1a6646292efbbd933585.tar.xz
biboumi-60569993b4532caffd8b1a6646292efbbd933585.zip
Make the password work when we join our first channel on that server
Because we need to wait for the welcome message, when we connect to the server, before sending the JOIN command, we need to also save the value of the password to reuse it when we actually send the JOIN command
-rw-r--r--src/irc/irc_client.cpp10
-rw-r--r--src/irc/irc_client.hpp14
2 files changed, 13 insertions, 11 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index a29fb0a..12f39d6 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -74,9 +74,9 @@ void IrcClient::on_connection_failed(const std::string& reason)
if (this->ports_to_try.empty())
{
// Send an error message for all room that the user wanted to join
- for (const std::string& channel: this->channels_to_join)
+ for (const auto& tuple: this->channels_to_join)
{
- Iid iid(channel + "%" + this->hostname);
+ Iid iid(std::get<0>(tuple) + "%" + this->hostname);
this->bridge->send_presence_error(iid, this->current_nick,
"cancel", "item-not-found",
"", reason);
@@ -209,7 +209,7 @@ void IrcClient::send_quit_command(const std::string& reason)
void IrcClient::send_join_command(const std::string& chan_name, const std::string& password)
{
if (this->welcomed == false)
- this->channels_to_join.push_back(chan_name);
+ this->channels_to_join.emplace_back(chan_name, password);
else
this->send_message(IrcMessage("JOIN", {chan_name, password}));
this->start();
@@ -536,8 +536,8 @@ void IrcClient::on_welcome_message(const IrcMessage& message)
// Install a repeated events to regularly send a PING
TimedEventsManager::instance().add_event(TimedEvent(240s, std::bind(&IrcClient::send_ping_command, this),
"PING"s + this->hostname + this->bridge->get_jid()));
- for (const std::string& chan_name: this->channels_to_join)
- this->send_join_command(chan_name);
+ for (const auto& tuple: this->channels_to_join)
+ this->send_join_command(std::get<0>(tuple), std::get<1>(tuple));
this->channels_to_join.clear();
// Indicate that the dummy channel is joined as well, if needed
if (this->dummy_channel.joining)
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 29da868..578fce2 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -8,6 +8,7 @@
#include <network/tcp_socket_handler.hpp>
#include <unordered_map>
+#include <utility>
#include <memory>
#include <vector>
#include <string>
@@ -81,7 +82,7 @@ public:
/**
* Send the JOIN irc command.
*/
- void send_join_command(const std::string& chan_name, const std::string& password = "");
+ void send_join_command(const std::string& chan_name, const std::string& password);
/**
* Send a PRIVMSG command for a channel
* Return true if the message was actually sent
@@ -245,12 +246,13 @@ private:
*/
DummyIrcChannel dummy_channel;
/**
- * A list of chan we want to join, but we need a response 001 from
- * the server before sending the actual JOIN commands. So we just keep the
- * channel names in a list, and send the JOIN commands for each of them
- * whenever the WELCOME message is received.
+ * A list of chan we want to join (tuples with the channel name and the
+ * password, if any), but we need a response 001 from the server before
+ * sending the actual JOIN commands. So we just keep the channel names in
+ * a list, and send the JOIN commands for each of them whenever the
+ * WELCOME message is received.
*/
- std::vector<std::string> channels_to_join;
+ std::vector<std::tuple<std::string, std::string>> channels_to_join;
/**
* This flag indicates that the server is completely joined (connection
* has been established, we are authentified and we have a nick)