summaryrefslogtreecommitdiffstats
path: root/src/Server/RequestHandlers
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-05-21 00:42:57 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-05-21 00:42:57 +0200
commit9c076d2649ff8c6997c2dec1e1ef4f7359d404ec (patch)
tree2e73f262998fe27326459c69605554b150eb6c82 /src/Server/RequestHandlers
parent325ee09f8fa61185efd6ec8b64b6432686170ac8 (diff)
downloadmad-9c076d2649ff8c6997c2dec1e1ef4f7359d404ec.tar
mad-9c076d2649ff8c6997c2dec1e1ef4f7359d404ec.zip
UserBackend-Interface ueberarbeitet
Diffstat (limited to 'src/Server/RequestHandlers')
-rw-r--r--src/Server/RequestHandlers/UserInfoRequestHandler.cpp30
-rw-r--r--src/Server/RequestHandlers/UserInfoRequestHandler.h6
-rw-r--r--src/Server/RequestHandlers/UserListRequestHandler.cpp39
-rw-r--r--src/Server/RequestHandlers/UserListRequestHandler.h6
4 files changed, 31 insertions, 50 deletions
diff --git a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp b/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
index 740c2a9..287d026 100644
--- a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
+++ b/src/Server/RequestHandlers/UserInfoRequestHandler.cpp
@@ -22,8 +22,6 @@
#include <Net/Exception.h>
#include <Common/Logger.h>
-#include <boost/bind.hpp>
-
namespace Mad {
namespace Server {
namespace RequestHandlers {
@@ -44,24 +42,22 @@ void UserInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) {
// TODO Require authentication
- if(!UserManager::get()->getUserInfo(packet["uid"], boost::bind(&UserInfoRequestHandler::userInfoHandler, this, _1))) {
- Common::XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED);
-
- sendPacket(ret);
- signalFinished()();
- }
-}
+ boost::shared_ptr<Common::UserInfo> info = UserManager::get()->getUserInfo(packet["uid"]);
-void UserInfoRequestHandler::userInfoHandler(const Common::UserInfo &info) {
Common::XmlPacket ret;
- ret.setType("OK");
- ret.add("uid", info.getUid());
- ret.add("gid", info.getGid());
- ret.add("username", info.getUsername());
- ret.add("fullName", info.getFullName());
+ if(info) {
+ ret.setType("OK");
+
+ ret.add("uid", info->getUid());
+ ret.add("gid", info->getGid());
+ ret.add("username", info->getUsername());
+ ret.add("fullName", info->getFullName());
+ }
+ else {
+ ret.setType("Error");
+ ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED);
+ }
sendPacket(ret);
signalFinished()();
diff --git a/src/Server/RequestHandlers/UserInfoRequestHandler.h b/src/Server/RequestHandlers/UserInfoRequestHandler.h
index 5b1d466..90032f0 100644
--- a/src/Server/RequestHandlers/UserInfoRequestHandler.h
+++ b/src/Server/RequestHandlers/UserInfoRequestHandler.h
@@ -21,18 +21,12 @@
#define MAD_SERVER_REQUESTHANDLERS_USERINFOREQUESTHANDLER_H_
#include <Common/RequestHandler.h>
-#include <Common/UserInfo.h>
-
-#include <map>
namespace Mad {
namespace Server {
namespace RequestHandlers {
class UserInfoRequestHandler : public Common::RequestHandler {
- private:
- void userInfoHandler(const Common::UserInfo &info);
-
protected:
virtual void handlePacket(const Common::XmlPacket &packet);
diff --git a/src/Server/RequestHandlers/UserListRequestHandler.cpp b/src/Server/RequestHandlers/UserListRequestHandler.cpp
index cd05c12..713753b 100644
--- a/src/Server/RequestHandlers/UserListRequestHandler.cpp
+++ b/src/Server/RequestHandlers/UserListRequestHandler.cpp
@@ -22,8 +22,6 @@
#include <Net/Exception.h>
#include <Common/Logger.h>
-#include <boost/bind.hpp>
-
namespace Mad {
namespace Server {
namespace RequestHandlers {
@@ -44,29 +42,28 @@ void UserListRequestHandler::handlePacket(const Common::XmlPacket &packet) {
// TODO Require authentication
- if(!UserManager::get()->getUserList(boost::bind(&UserListRequestHandler::userListHandler, this, _1))) {
- Common::XmlPacket ret;
- ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED);
-
- sendPacket(ret);
- signalFinished()();
- }
-}
+ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > info = UserManager::get()->getUserList();
-void UserListRequestHandler::userListHandler(const std::map<unsigned long, Common::UserInfo> &info) {
Common::XmlPacket ret;
- ret.setType("OK");
- ret.addList("users");
- for(std::map<unsigned long, Common::UserInfo>::const_iterator user = info.begin(); user != info.end(); ++user) {
- ret["users"].addEntry();
- Common::XmlPacket::Entry &entry = ret["users"].back();
+ if(info) {
+ ret.setType("OK");
+ ret.addList("users");
- entry.add("uid", user->second.getUid());
- entry.add("gid", user->second.getGid());
- entry.add("username", user->second.getUsername());
- entry.add("fullName", user->second.getFullName());
+ for(std::map<unsigned long, Common::UserInfo>::iterator user = info->begin(); user != info->end(); ++user) {
+ ret["users"].addEntry();
+ Common::XmlPacket::Entry &entry = ret["users"].back();
+
+ entry.add("uid", user->second.getUid());
+ entry.add("gid", user->second.getGid());
+ entry.add("username", user->second.getUsername());
+ entry.add("fullName", user->second.getFullName());
+ }
+ }
+
+ else {
+ ret.setType("Error");
+ ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED);
}
sendPacket(ret);
diff --git a/src/Server/RequestHandlers/UserListRequestHandler.h b/src/Server/RequestHandlers/UserListRequestHandler.h
index 7c85aa0..4b1a385 100644
--- a/src/Server/RequestHandlers/UserListRequestHandler.h
+++ b/src/Server/RequestHandlers/UserListRequestHandler.h
@@ -21,18 +21,12 @@
#define MAD_SERVER_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_
#include <Common/RequestHandler.h>
-#include <Common/UserInfo.h>
-
-#include <map>
namespace Mad {
namespace Server {
namespace RequestHandlers {
class UserListRequestHandler : public Common::RequestHandler {
- private:
- void userListHandler(const std::map<unsigned long, Common::UserInfo> &info);
-
protected:
virtual void handlePacket(const Common::XmlPacket &packet);