From d71b6a8b273ae6efc823ffe79130e6a85b6a1534 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Mon, 1 Apr 2013 18:00:17 +0200 Subject: Remove the deprecated invite API --- include/users.h | 13 ++++--------- src/channels.cpp | 4 ++-- src/commands/cmd_invite.cpp | 11 ++++++++--- src/modules/m_override.cpp | 3 +-- src/modules/m_uninvite.cpp | 4 +--- src/users.cpp | 32 +++++++------------------------- 6 files changed, 23 insertions(+), 44 deletions(-) diff --git a/include/users.h b/include/users.h index 34bcc9c73..def7a146d 100644 --- a/include/users.h +++ b/include/users.h @@ -832,23 +832,18 @@ class CoreExport LocalUser : public User, public InviteBase InviteList& GetInviteList(); /** Returns true if a user is invited to a channel. - * @param channel A channel name to look up + * @param channel A channel to look up * @return True if the user is invited to the given channel */ - bool IsInvited(const irc::string &channel); - - /** Adds a channel to a users invite list (invites them to a channel) - * @param channel A channel name to add - * @param timeout When the invite should expire (0 == never) - */ - void InviteTo(const irc::string &channel, time_t timeout); + bool IsInvited(Channel* chan) { return (Invitation::Find(chan, this) != NULL); } /** Removes a channel from a users invite list. * This member function is called on successfully joining an invite only channel * to which the user has previously been invited, to clear the invitation. * @param channel The channel to remove the invite to + * @return True if the user was invited to the channel and the invite was erased, false if the user wasn't invited */ - void RemoveInvite(const irc::string &channel); + bool RemoveInvite(Channel* chan); void RemoveExpiredInvites(); diff --git a/src/channels.cpp b/src/channels.cpp index 7138880ff..b8406a65a 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -319,7 +319,7 @@ Channel* Channel::JoinUser(User* user, std::string cname, bool override, const s else if (MOD_RESULT == MOD_RES_PASSTHRU) { std::string ckey = Ptr->GetModeParameter('k'); - bool invited = IS_LOCAL(user)->IsInvited(Ptr->name.c_str()); + bool invited = IS_LOCAL(user)->IsInvited(Ptr); bool can_bypass = ServerInstance->Config->InvBypassModes && invited; if (!ckey.empty()) @@ -366,7 +366,7 @@ Channel* Channel::JoinUser(User* user, std::string cname, bool override, const s */ if (invited) { - IS_LOCAL(user)->RemoveInvite(Ptr->name.c_str()); + IS_LOCAL(user)->RemoveInvite(Ptr); } } } diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp index 11cb549af..6e5aead12 100644 --- a/src/commands/cmd_invite.cpp +++ b/src/commands/cmd_invite.cpp @@ -107,9 +107,14 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use } if (IS_LOCAL(u)) - IS_LOCAL(u)->InviteTo(c->name.c_str(), timeout); - u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name.c_str()); - user->WriteNumeric(RPL_INVITING, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); + { + Invitation::Create(c, IS_LOCAL(u), timeout); + u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name.c_str()); + } + + if (IS_LOCAL(user)) + user->WriteNumeric(RPL_INVITING, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); + if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE) { char prefix; diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index ea9d11c94..29996fc8f 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -124,8 +124,7 @@ class ModuleOverride : public Module { if (chan->IsModeSet('i') && (CanOverride(user,"INVITE"))) { - irc::string x(chan->name.c_str()); - if (!IS_LOCAL(user)->IsInvited(x)) + if (!IS_LOCAL(user)->IsInvited(chan)) { if (RequireKey && keygiven != "override") { diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index 683976885..f429f75b9 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -70,15 +70,13 @@ class CommandUninvite : public Command LocalUser* lu = IS_LOCAL(u); if (lu) { - irc::string xname(c->name.c_str()); - if (!lu->IsInvited(xname)) + if (!lu->RemoveInvite(c)) { user->SendText(":%s 505 %s %s %s :Is not invited to channel %s", user->server.c_str(), user->nick.c_str(), u->nick.c_str(), c->name.c_str(), c->name.c_str()); return CMD_FAILURE; } user->SendText(":%s 494 %s %s %s :Uninvited", user->server.c_str(), user->nick.c_str(), c->name.c_str(), u->nick.c_str()); - lu->RemoveInvite(xname); lu->WriteNumeric(493, "%s :You were uninvited from %s by %s", u->nick.c_str(), c->name.c_str(), user->nick.c_str()); std::string msg = "*** " + user->nick + " uninvited " + u->nick + "."; diff --git a/src/users.cpp b/src/users.cpp index fb7c46d6b..c53fb7853 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -332,40 +332,22 @@ const std::string& User::GetFullRealHost() return this->cached_fullrealhost; } -bool LocalUser::IsInvited(const irc::string &channel) -{ - Channel* chan = ServerInstance->FindChan(channel.c_str()); - if (!chan) - return false; - - return (Invitation::Find(chan, this) != NULL); -} - InviteList& LocalUser::GetInviteList() { RemoveExpiredInvites(); return invites; } -void LocalUser::InviteTo(const irc::string &channel, time_t invtimeout) -{ - Channel* chan = ServerInstance->FindChan(channel.c_str()); - if (chan) - Invitation::Create(chan, this, invtimeout); -} - -void LocalUser::RemoveInvite(const irc::string &channel) +bool LocalUser::RemoveInvite(Channel* chan) { - Channel* chan = ServerInstance->FindChan(channel.c_str()); - if (chan) + Invitation* inv = Invitation::Find(chan, this); + if (inv) { - Invitation* inv = Invitation::Find(chan, this); - if (inv) - { - inv->cull(); - delete inv; - } + inv->cull(); + delete inv; + return true; } + return false; } void LocalUser::RemoveExpiredInvites() -- cgit v1.2.3