diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-06-19 18:21:03 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-06-19 18:21:03 +0200 |
commit | 37c8bed9a5f2ae9141c461202fec5baa6fa21389 (patch) | |
tree | d29b6a74b4da709350beec3c12c91426bcd4dea8 /src | |
parent | 7234fe326d16d6bf9f4374a09ddc6ef790e6723f (diff) | |
download | mad-37c8bed9a5f2ae9141c461202fec5baa6fa21389.tar mad-37c8bed9a5f2ae9141c461202fec5baa6fa21389.zip |
UserManager nach Common verschoben
Diffstat (limited to 'src')
-rw-r--r-- | src/Common/Application.cpp | 4 | ||||
-rw-r--r-- | src/Common/Application.h | 6 | ||||
-rw-r--r-- | src/Common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Common/UserBackend.h (renamed from src/Server/UserBackend.h) | 16 | ||||
-rw-r--r-- | src/Common/UserManager.cpp (renamed from src/Server/UserManager.cpp) | 12 | ||||
-rw-r--r-- | src/Common/UserManager.h (renamed from src/Server/UserManager.h) | 16 | ||||
-rw-r--r-- | src/Server/Application.cpp | 7 | ||||
-rw-r--r-- | src/Server/Application.h | 6 | ||||
-rw-r--r-- | src/Server/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Server/RequestHandlers/UserRequestHandlerGroup.cpp | 2 | ||||
-rw-r--r-- | src/modules/UserBackendMysql/Module.h | 13 | ||||
-rw-r--r-- | src/modules/UserBackendMysql/UserBackendMysql.h | 5 |
12 files changed, 40 insertions, 51 deletions
diff --git a/src/Common/Application.cpp b/src/Common/Application.cpp index 950e61b..6eca8d3 100644 --- a/src/Common/Application.cpp +++ b/src/Common/Application.cpp @@ -21,14 +21,16 @@ #include "ModuleManager.h" #include "RequestManager.h" #include "SystemManager.h" +#include "UserManager.h" namespace Mad { namespace Common { Application::Application(bool server) : moduleManager(new ModuleManager(this)), requestManager(new RequestManager(this, server)), -systemManager(new SystemManager) {} +systemManager(new SystemManager), userManager(new UserManager) {} Application::~Application() { + delete userManager; delete systemManager; delete requestManager; delete moduleManager; diff --git a/src/Common/Application.h b/src/Common/Application.h index 332e4c7..9da1f03 100644 --- a/src/Common/Application.h +++ b/src/Common/Application.h @@ -28,12 +28,14 @@ namespace Common { class ModuleManager; class RequestManager; class SystemManager; +class UserManager; class Application : public Core::Application { private: ModuleManager *moduleManager; RequestManager *requestManager; SystemManager *systemManager; + UserManager *userManager; protected: Application(bool server); @@ -51,6 +53,10 @@ class Application : public Core::Application { SystemManager* getSystemManager() const { return systemManager; } + + UserManager* getUserManager() const { + return userManager; + } }; } diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 4a4eb8e..3ec77c4 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -20,7 +20,9 @@ add_library(Common RequestManager.cpp RequestManager.h SystemBackend.h SystemManager.cpp SystemManager.h + UserBackend.h UserInfo.h + UserManager.cpp UserManager.h XmlPacket.cpp XmlPacket.h ) target_link_libraries(Common RequestHandlers Requests Net ${LIBXML2_LIBRARIES} ${LTDL_LIBRARIES}) diff --git a/src/Server/UserBackend.h b/src/Common/UserBackend.h index 4688bc7..16db16c 100644 --- a/src/Server/UserBackend.h +++ b/src/Common/UserBackend.h @@ -24,8 +24,8 @@ #include <Core/Exception.h> -#include <Common/UserInfo.h> -#include <Common/GroupInfo.h> +#include "UserInfo.h" +#include "GroupInfo.h" #include <map> #include <set> @@ -35,7 +35,7 @@ namespace Mad { -namespace Server { +namespace Common { class UserManager; @@ -45,15 +45,15 @@ class UserBackend { UserBackend() {} - virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception) { + virtual boost::shared_ptr<std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } - virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) { + virtual boost::shared_ptr<UserInfo> getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } - virtual boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) { + virtual boost::shared_ptr<UserInfo> getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } @@ -62,7 +62,7 @@ class UserBackend { } - virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception) { + virtual boost::shared_ptr<std::map<unsigned long, GroupInfo> > getGroupList() throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } @@ -82,7 +82,7 @@ class UserBackend { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } - virtual void addUser(const Common::UserInfo &userInfo _UNUSED_PARAMETER_) throw(Core::Exception) { + virtual void addUser(const UserInfo &userInfo _UNUSED_PARAMETER_) throw(Core::Exception) { throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED)); } diff --git a/src/Server/UserManager.cpp b/src/Common/UserManager.cpp index 243457c..6f5f548 100644 --- a/src/Server/UserManager.cpp +++ b/src/Common/UserManager.cpp @@ -21,7 +21,7 @@ #include "UserBackend.h" namespace Mad { -namespace Server { +namespace Common { bool UserManager::Compare::operator() (boost::shared_ptr<UserBackend> b1, boost::shared_ptr<UserBackend> b2) { if(b1->getPriority() == b2->getPriority()) @@ -31,7 +31,7 @@ bool UserManager::Compare::operator() (boost::shared_ptr<UserBackend> b1, boost: } -boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserManager::getUserList() throw(Core::Exception) { +boost::shared_ptr<std::map<unsigned long, UserInfo> > UserManager::getUserList() throw(Core::Exception) { Core::Exception e(Core::Exception::NOT_IMPLEMENTED); for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { @@ -47,7 +47,7 @@ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserManager::getUs throw e; } -boost::shared_ptr<Common::UserInfo> UserManager::getUserInfo(unsigned long uid) throw(Core::Exception) { +boost::shared_ptr<UserInfo> UserManager::getUserInfo(unsigned long uid) throw(Core::Exception) { Core::Exception e(Core::Exception::NOT_IMPLEMENTED); for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { @@ -63,7 +63,7 @@ boost::shared_ptr<Common::UserInfo> UserManager::getUserInfo(unsigned long uid) throw e; } -boost::shared_ptr<Common::UserInfo> UserManager::getUserInfoByName(const std::string &name) throw(Core::Exception) { +boost::shared_ptr<UserInfo> UserManager::getUserInfoByName(const std::string &name) throw(Core::Exception) { Core::Exception e(Core::Exception::NOT_IMPLEMENTED); for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { @@ -95,7 +95,7 @@ boost::shared_ptr<std::set<unsigned long> > UserManager::getUserGroupList(unsign throw e; } -boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserManager::getGroupList() throw(Core::Exception) { +boost::shared_ptr<std::map<unsigned long, GroupInfo> > UserManager::getGroupList() throw(Core::Exception) { Core::Exception e(Core::Exception::NOT_IMPLEMENTED); for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { @@ -175,7 +175,7 @@ void UserManager::setPassword(unsigned long uid, const std::string &password) th throw e; } -void UserManager::addUser(const Common::UserInfo &userInfo) throw(Core::Exception) { +void UserManager::addUser(const UserInfo &userInfo) throw(Core::Exception) { Core::Exception e(Core::Exception::NOT_IMPLEMENTED); for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { diff --git a/src/Server/UserManager.h b/src/Common/UserManager.h index 6d3c034..bdf39c1 100644 --- a/src/Server/UserManager.h +++ b/src/Common/UserManager.h @@ -20,8 +20,8 @@ #ifndef MAD_SERVER_USERMANAGER_H_ #define MAD_SERVER_USERMANAGER_H_ -#include <Common/UserInfo.h> -#include <Common/GroupInfo.h> +#include "UserInfo.h" +#include "GroupInfo.h" #include <Core/Exception.h> @@ -32,7 +32,7 @@ #include <boost/noncopyable.hpp> namespace Mad { -namespace Server { +namespace Common { class Application; class UserBackend; @@ -58,19 +58,19 @@ class UserManager : boost::noncopyable { backends.erase(backend); } - boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception); - boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception); - boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception); + boost::shared_ptr<std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception); + boost::shared_ptr<UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception); + boost::shared_ptr<UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception); boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception); - boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception); + boost::shared_ptr<std::map<unsigned long, GroupInfo> > getGroupList() throw(Core::Exception); std::string getGroupName(unsigned long gid) throw(Core::Exception); unsigned long getGroupId(const std::string &name) throw(Core::Exception); boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception); void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception); - void addUser(const Common::UserInfo &userInfo) throw(Core::Exception); + void addUser(const UserInfo &userInfo) throw(Core::Exception); }; } diff --git a/src/Server/Application.cpp b/src/Server/Application.cpp index 3414e53..dc9fa5f 100644 --- a/src/Server/Application.cpp +++ b/src/Server/Application.cpp @@ -19,18 +19,13 @@ #include "Application.h" #include "ConnectionManager.h" -#include "UserManager.h" namespace Mad { namespace Server { -Application::Application() : Common::Application(true), connectionManager(new ConnectionManager(this)), -userManager(new UserManager) { - -} +Application::Application() : Common::Application(true), connectionManager(new ConnectionManager(this)) {} Application::~Application() { - delete userManager; delete connectionManager; } diff --git a/src/Server/Application.h b/src/Server/Application.h index b62893b..600458f 100644 --- a/src/Server/Application.h +++ b/src/Server/Application.h @@ -26,12 +26,10 @@ namespace Mad { namespace Server { class ConnectionManager; -class UserManager; class Application : public Common::Application { private: ConnectionManager *connectionManager; - UserManager *userManager; public: Application(); @@ -40,10 +38,6 @@ class Application : public Common::Application { ConnectionManager* getConnectionManager() const { return connectionManager; } - - UserManager* getUserManager() const { - return userManager; - } }; } diff --git a/src/Server/CMakeLists.txt b/src/Server/CMakeLists.txt index b609de3..22a7826 100644 --- a/src/Server/CMakeLists.txt +++ b/src/Server/CMakeLists.txt @@ -6,7 +6,5 @@ include_directories(${INCLUDES}) add_library(Server Application.cpp Application.h ConnectionManager.cpp ConnectionManager.h - UserBackend.h - UserManager.cpp UserManager.h ) target_link_libraries(Server ServerRequestHandlers ServerRequests Common) diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp index 3aaa576..34fae36 100644 --- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp +++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp @@ -19,7 +19,7 @@ #include "UserRequestHandlerGroup.h" #include "../Application.h" -#include "../UserManager.h" +#include <Common/UserManager.h> namespace Mad { namespace Server { diff --git a/src/modules/UserBackendMysql/Module.h b/src/modules/UserBackendMysql/Module.h index 31f6692..96be5a7 100644 --- a/src/modules/UserBackendMysql/Module.h +++ b/src/modules/UserBackendMysql/Module.h @@ -22,8 +22,7 @@ #include "UserBackendMysql.h" -#include <Server/Application.h> -#include <Server/UserManager.h> +#include <Common/UserManager.h> #include <Common/Module.h> namespace Mad { @@ -38,17 +37,11 @@ class Module : public Common::Module { public: Module(Common::Application *application0) : application(application0), backend(new UserBackendMysql(application)) { - Server::Application *app = dynamic_cast<Server::Application*>(application); - - if(app) - app->getUserManager()->registerBackend(backend); + application->getUserManager()->registerBackend(backend); } virtual ~Module() { - Server::Application *app = dynamic_cast<Server::Application*>(application); - - if(app) - app->getUserManager()->unregisterBackend(backend); + application->getUserManager()->unregisterBackend(backend); } }; diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h index aa141da..77f0700 100644 --- a/src/modules/UserBackendMysql/UserBackendMysql.h +++ b/src/modules/UserBackendMysql/UserBackendMysql.h @@ -20,8 +20,7 @@ #ifndef MAD_MODULES_USERBACKENDMYSQL_USERBACKENDMYSQL_H_ #define MAD_MODULES_USERBACKENDMYSQL_USERBACKENDMYSQL_H_ -#include <Server/UserBackend.h> - +#include <Common/UserBackend.h> #include <Common/Application.h> #include <Core/Configurable.h> @@ -33,7 +32,7 @@ namespace Mad { namespace Modules { namespace UserBackendMysql { -class UserBackendMysql : public Server::UserBackend, private Core::Configurable { +class UserBackendMysql : public Common::UserBackend, private Core::Configurable { private: Common::Application *application; |