/* * UserManager.cpp * * Copyright (C) 2009 Matthias Schiffer * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "UserManager.h" #include "UserBackend.h" namespace Mad { namespace Server { UserManager UserManager::userManager; bool UserManager::Compare::operator() (boost::shared_ptr b1, boost::shared_ptr b2) { if(b1->getPriority() == b2->getPriority()) return (b1.get() > b2.get()); else return (b1->getPriority() > b2->getPriority()); } boost::shared_ptr > UserManager::getUserList() throw(Net::Exception) { Net::Exception e(Net::Exception::NOT_IMPLEMENTED); for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { try { return (*backend)->getUserList(); } catch(Net::Exception e2) { if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) e = e2; } } throw e; } boost::shared_ptr UserManager::getUserInfo(unsigned long uid) throw(Net::Exception) { Net::Exception e(Net::Exception::NOT_IMPLEMENTED); for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { try { return (*backend)->getUserInfo(uid); } catch(Net::Exception e2) { if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) e = e2; } } throw e; } boost::shared_ptr > UserManager::getGroupList() throw(Net::Exception) { Net::Exception e(Net::Exception::NOT_IMPLEMENTED); for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { try { return (*backend)->getGroupList(); } catch(Net::Exception e2) { if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) e = e2; } } throw e; } void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Net::Exception) { Net::Exception e(Net::Exception::NOT_IMPLEMENTED); for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { try { return (*backend)->setPassword(uid, password); } catch(Net::Exception e2) { if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) e = e2; } } throw e; } void UserManager::addUser(const Common::UserInfo &userInfo) throw(Net::Exception) { Net::Exception e(Net::Exception::NOT_IMPLEMENTED); for(std::set >::iterator backend = backends.begin(); backend != backends.end(); ++backend) { try { return (*backend)->addUser(userInfo); } catch(Net::Exception e2) { if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED) e = e2; } } throw e; } } }