From 40079f3d50a559ea36705b72b2fe2d190a6cc354 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Fri, 26 Jul 2013 19:33:05 +0300 Subject: [PATCH] Added a function that lists all plugins that authorize the user. --- include/stg/user.h | 4 ++++ projects/stargazer/user_impl.cpp | 9 +++++++++ projects/stargazer/user_impl.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/include/stg/user.h b/include/stg/user.h index b9d638d6..0adb342a 100644 --- a/include/stg/user.h +++ b/include/stg/user.h @@ -24,6 +24,9 @@ #include #include +#include +#include + #include "os_int.h" #include "notifer.h" #include "message.h" @@ -77,6 +80,7 @@ public: const AUTH * auth) = 0; virtual void Unauthorize(const AUTH * auth) = 0;*/ virtual bool IsAuthorizedBy(const AUTH * auth) const = 0; + virtual std::vector GetAuthorizers() const = 0; virtual int AddMessage(STG_MSG * msg) = 0; diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index ac8399ca..5bb0069f 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include "stg/users.h" #include "stg/common.h" @@ -566,6 +568,13 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); return authorizedBy.find(auth) != authorizedBy.end(); } //----------------------------------------------------------------------------- +std::vector USER_IMPL::GetAuthorizers() const +{ + std::vector list; + std::transform(authorizedBy.begin(), authorizedBy.end(), std::back_inserter(list), std::mem_fun(&AUTH::GetVersion)); + return list; +} +//----------------------------------------------------------------------------- void USER_IMPL::Connect(bool fakeConnect) { /* diff --git a/projects/stargazer/user_impl.h b/projects/stargazer/user_impl.h index 5e8f49db..a581f2e5 100644 --- a/projects/stargazer/user_impl.h +++ b/projects/stargazer/user_impl.h @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -186,6 +187,7 @@ public: int Authorize(uint32_t ip, uint32_t enabledDirs, const AUTH * auth); void Unauthorize(const AUTH * auth); bool IsAuthorizedBy(const AUTH * auth) const; + std::vector GetAuthorizers() const; int AddMessage(STG_MSG * msg); -- 2.44.2