00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "NickPair.h"
00017
00018
00019 void NickPair::send_nick(std::string const& nick)
00020 {
00021 DoutEntering(dc::debug, "NickPair::send_nick(\"" << nick << "\")");
00022 if (!M_out_nicks.empty() && M_out_nicks.back() == nick)
00023 {
00024 Dout(dc::notice, "The last nick sent to the server was the same! Ignoring request.");
00025 return;
00026 }
00027 M_session << "NICK " << nick << "\r\n";
00028 M_out_nick = nick;
00029 M_out_nicks.push_back(nick);
00030 }
00031
00032
00033
00034
00035
00036
00037
00038 bool NickPair::nick_received(std::string const& nick)
00039 {
00040 DoutEntering(dc::debug, "NickPair::nick_received(\"" << nick << "\")");
00041 if (M_out_nicks.empty() || M_out_nicks.front() != nick)
00042 {
00043 Dout(dc::debug, "Not my nick.");
00044 return false;
00045 }
00046 M_out_nicks.pop_back();
00047 M_in_nick = nick;
00048 if (M_out_nicks.empty())
00049 {
00050 Dout(dc::notice, "NickPair::M_out_nicks is empty. Current nick is now \"" << nick << "\".");
00051 }
00052 return true;
00053 }
00054
00055
00056 void NickPair::inuse(std::string const& nick)
00057 {
00058 DoutEntering(dc::debug, "NickPair::inuse(\"" << nick << "\")");
00059 ASSERT(!M_out_nicks.empty());
00060 ASSERT(M_out_nicks.front() == nick);
00061 M_out_nicks.pop_back();
00062 if (M_out_nicks.empty())
00063 {
00064 std::string new_nick(nick);
00065 new_nick += '_';
00066 ASSERT(new_nick != nick);
00067 send_nick(new_nick);
00068 }
00069 }
00070