Browse Source

Changed plugin event calls to be slightly safter. A plugin call removing a plugin will not longer cause bounds issues, though other plugins can still have their calls skipped.

release/0.19
JustinAJ 11 years ago
parent
commit
65b1ea6117
  1. 28
      Jupiter/IRC_Client.cpp

28
Jupiter/IRC_Client.cpp

@ -907,7 +907,7 @@ int Jupiter::IRC::Client::primaryHandler()
if (command.equals("ACTION"))
{
this->OnAction(chan, nick, message);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnAction(this, chan, nick, message);
}
else
@ -936,7 +936,7 @@ int Jupiter::IRC::Client::primaryHandler()
response += IRCCTCP ENDL;
Jupiter::IRC::Client::data_->sock->send(response);
this->OnCTCP(chan, nick, command, message);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnCTCP(this, chan, nick, message);
}
}
@ -944,7 +944,7 @@ int Jupiter::IRC::Client::primaryHandler()
{
Jupiter::CStringS message = premessage;
this->OnChat(chan, nick, message);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnChat(this, chan, nick, message);
}
}
@ -961,7 +961,7 @@ int Jupiter::IRC::Client::primaryHandler()
{
auto nick = buff.substring(1, pos);
this->OnNotice(chan, nick, message);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnNotice(this, chan, nick, message);
}
else
@ -970,7 +970,7 @@ int Jupiter::IRC::Client::primaryHandler()
if (sender.size() != 0)
{
this->OnServerNotice(chan, sender, message);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnServerNotice(this, chan, sender, message);
}
}
@ -992,7 +992,7 @@ int Jupiter::IRC::Client::primaryHandler()
user->data_->nickname = newnick;
this->OnNick(nick, newnick);
}
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnNick(this, nick, newnick);
}
else if (w2.equalsi("JOIN"))
@ -1103,7 +1103,7 @@ int Jupiter::IRC::Client::primaryHandler()
Jupiter::ReferenceString invited = Jupiter::ReferenceString::getWord(buff, 2, WHITESPACE);
Jupiter::CStringS chan = buff.c_str() + findSymbol(buff.c_str(), ':', 1) + 1;
this->OnInvite(chan, inviter, invited);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnInvite(this, chan, inviter, invited);
}
else if (w2.equalsi("MODE"))
@ -1161,7 +1161,7 @@ int Jupiter::IRC::Client::primaryHandler()
}
Jupiter::CStringS modeString = modestring;
this->OnMode(chan, nick, modeString);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnMode(this, chan, nick, modeString);
}
}
@ -1208,7 +1208,7 @@ int Jupiter::IRC::Client::primaryHandler()
{
Jupiter::CStringS reason = buff.c_str() + strcspn(buff.c_str(), ":") + 1;
this->OnError(reason);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnError(this, reason);
Jupiter::IRC::Client::disconnect();
}
@ -1238,12 +1238,12 @@ int Jupiter::IRC::Client::primaryHandler()
if (numeric != 0)
{
this->OnNumeric(numeric, buff);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnNumeric(this, numeric, buff);
}
}
this->OnRaw(buff);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnRaw(this, buff);
}
}
@ -1300,7 +1300,7 @@ void Jupiter::IRC::Client::disconnect(bool stayDead)
Jupiter::IRC::Client::data_->sock = t;
}
}
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnDisconnect(this);
}
@ -1316,14 +1316,14 @@ void Jupiter::IRC::Client::reconnect()
Jupiter::IRC::Client::data_->reconnectAttempts++;
bool successConnect = Jupiter::IRC::Client::connect();
this->OnReconnectAttempt(successConnect);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnReconnectAttempt(this, successConnect);
}
int Jupiter::IRC::Client::think()
{
int r = Jupiter::IRC::Client::primaryHandler();
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
Jupiter::plugins->get(i)->OnThink(this);
if (r)
{

Loading…
Cancel
Save