diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-01-26 15:05:22 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-01-26 15:05:22 +0100 |
commit | 045747290ba1088daf7f70d5d36d0eb4c8ba2b4e (patch) | |
tree | ed3798ff5f8606ab56edee40c37e84399d9fa736 /src/usermanager.cpp | |
parent | 1ea821e8c1c7a65f826553bea7d5b7503f04243d (diff) | |
parent | 4d4306d8a91387baf642d6e4703f87246c688d2f (diff) |
Merge branch 'master+foreachneighbor'
Diffstat (limited to 'src/usermanager.cpp')
-rw-r--r-- | src/usermanager.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 52cb4989f..5d07c4d79 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -24,6 +24,30 @@ #include "xline.h" #include "iohook.h" +namespace +{ + class WriteCommonQuit : public User::ForEachNeighborHandler + { + std::string line; + std::string operline; + + void Execute(LocalUser* user) CXX11_OVERRIDE + { + user->Write(user->IsOper() ? operline : line); + } + + public: + WriteCommonQuit(User* user, const std::string& msg, const std::string& opermsg) + : line(":" + user->GetFullHost() + " QUIT :") + , operline(line) + { + line += msg; + operline += opermsg; + user->ForEachNeighbor(*this, false); + } + }; +} + UserManager::UserManager() : unregistered_count(0) { @@ -180,7 +204,7 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: if (user->registered == REG_ALL) { FOREACH_MOD(OnUserQuit, (user, reason, *operreason)); - user->WriteCommonQuit(reason, *operreason); + WriteCommonQuit(user, reason, *operreason); } else unregistered_count--; |