summaryrefslogtreecommitdiffstats
path: root/src/Server
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-07-03 17:23:37 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-07-03 17:23:37 +0200
commitf2f1d5b1da4f985bcbb0c075cf42efcacecae2a6 (patch)
tree8ffe90bf55fb9bb7d4408f56b78b8b5ab9153153 /src/Server
parentb014b0c0c29553ed9a7a38278f5433d28b0f8751 (diff)
downloadmad-f2f1d5b1da4f985bcbb0c075cf42efcacecae2a6.tar
mad-f2f1d5b1da4f985bcbb0c075cf42efcacecae2a6.zip
Timestamps für Benutzercache
Diffstat (limited to 'src/Server')
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.cpp191
1 files changed, 152 insertions, 39 deletions
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
index d579480..292e887 100644
--- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
@@ -17,99 +17,196 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
+
#include "UserRequestHandlerGroup.h"
#include "../Application.h"
+
#include <Common/UserManager.h>
+#include <boost/date_time/posix_time/posix_time.hpp>
+
namespace Mad {
namespace Server {
namespace RequestHandlers {
-void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
+void UserRequestHandlerGroup::handleUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > info = application->getUserManager()->getUserList();
+ boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
+
+ const std::string &timestr = packet->get<const std::string&>("timestamp");
+ if(!timestr.empty()) {
+ try {
+ timestamp = boost::posix_time::from_iso_string(timestr);
+ }
+ catch(...) {}
+ }
+
+ boost::shared_ptr<const std::map<unsigned long, Common::UserInfo> > users = application->getUserManager()->getUserList(&timestamp);
ret->setType("OK");
- Common::XmlPacket::List *list = ret->createList("users");
- for(std::map<unsigned long, Common::UserInfo>::const_iterator user = info->begin(); user != info->end(); ++user) {
- Common::XmlPacket::List::iterator entry = list->addEntry();
+ if(!timestamp.is_not_a_date_time())
+ ret->set("timestamp", boost::posix_time::to_iso_string(timestamp));
+
+ if(users) {
+ Common::XmlPacket::List *list = ret->createList("users");
+
+ for(std::map<unsigned long, Common::UserInfo>::const_iterator user = users->begin(); user != users->end(); ++user) {
+ Common::XmlPacket::List::iterator entry = list->addEntry();
- entry->set("uid", user->second.getUid());
- entry->set("gid", user->second.getGid());
- entry->set("username", user->second.getUsername());
- entry->set("fullName", user->second.getFullName());
+ entry->set("uid", user->second.getUid());
+ entry->set("gid", user->second.getGid());
+ entry->set("username", user->second.getUsername());
+ entry->set("fullName", user->second.getFullName());
+ }
}
}
void UserRequestHandlerGroup::handleUserInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
+
+ const std::string &timestr = packet->get<const std::string&>("timestamp");
+ if(!timestr.empty()) {
+ try {
+ timestamp = boost::posix_time::from_iso_string(timestr);
+ }
+ catch(...) {}
+ }
+
boost::shared_ptr<const Common::UserInfo> info;
unsigned long uid = packet->get<unsigned long>("uid");
if(uid)
- info = application->getUserManager()->getUserInfo(uid);
+ info = application->getUserManager()->getUserInfo(uid, &timestamp);
else
- info = application->getUserManager()->getUserInfoByName(packet->get<const std::string&>("name"));
+ info = application->getUserManager()->getUserInfoByName(packet->get<const std::string&>("name"), &timestamp);
ret->setType("OK");
- ret->set("uid", info->getUid());
- ret->set("gid", info->getGid());
- ret->set("username", info->getUsername());
- ret->set("fullName", info->getFullName());
+ if(!timestamp.is_not_a_date_time())
+ ret->set("timestamp", boost::posix_time::to_iso_string(timestamp));
+
+ if(info) {
+ ret->set("uid", info->getUid());
+ ret->set("gid", info->getGid());
+ ret->set("username", info->getUsername());
+ ret->set("fullName", info->getFullName());
+ }
}
void UserRequestHandlerGroup::handleUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<const std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid"));
+ boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
+
+ const std::string &timestr = packet->get<const std::string&>("timestamp");
+ if(!timestr.empty()) {
+ try {
+ timestamp = boost::posix_time::from_iso_string(timestr);
+ }
+ catch(...) {}
+ }
+
+ boost::shared_ptr<const std::set<unsigned long> > groups = application->getUserManager()->getUserGroupList(packet->get<unsigned long>("uid"), &timestamp);
ret->setType("OK");
- Common::XmlPacket::List *list = ret->createList("groups");
- for(std::set<unsigned long>::const_iterator group = groups->begin(); group != groups->end(); ++group) {
- Common::XmlPacket::List::iterator entry = list->addEntry();
+ if(!timestamp.is_not_a_date_time())
+ ret->set("timestamp", boost::posix_time::to_iso_string(timestamp));
+
+ if(groups) {
+ Common::XmlPacket::List *list = ret->createList("groups");
+
+ for(std::set<unsigned long>::const_iterator group = groups->begin(); group != groups->end(); ++group) {
+ Common::XmlPacket::List::iterator entry = list->addEntry();
- entry->set("gid", *group);
+ entry->set("gid", *group);
+ }
}
}
-void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
+void UserRequestHandlerGroup::handleGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > info = application->getUserManager()->getGroupList();
+ boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
+
+ const std::string &timestr = packet->get<const std::string&>("timestamp");
+ if(!timestr.empty()) {
+ try {
+ timestamp = boost::posix_time::from_iso_string(timestr);
+ }
+ catch(...) {}
+ }
+
+ boost::shared_ptr<const std::map<unsigned long, Common::GroupInfo> > groups = application->getUserManager()->getGroupList(&timestamp);
ret->setType("OK");
- Common::XmlPacket::List *list = ret->createList("groups");
- for(std::map<unsigned long, Common::GroupInfo>::const_iterator group = info->begin(); group != info->end(); ++group) {
- Common::XmlPacket::List::iterator entry = list->addEntry();
+ if(!timestamp.is_not_a_date_time())
+ ret->set("timestamp", boost::posix_time::to_iso_string(timestamp));
+
+ if(groups) {
+ Common::XmlPacket::List *list = ret->createList("groups");
+
+ for(std::map<unsigned long, Common::GroupInfo>::const_iterator group = groups->begin(); group != groups->end(); ++group) {
+ Common::XmlPacket::List::iterator entry = list->addEntry();
- entry->set("gid", group->second.getGid());
- entry->set("name", group->second.getName());
+ entry->set("gid", group->second.getGid());
+ entry->set("name", group->second.getName());
+ }
}
}
void UserRequestHandlerGroup::handleGroupInfoRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
+ boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
+
+ const std::string &timestr = packet->get<const std::string&>("timestamp");
+ if(!timestr.empty()) {
+ try {
+ timestamp = boost::posix_time::from_iso_string(timestr);
+ }
+ catch(...) {}
+ }
+
boost::shared_ptr<const Common::GroupInfo> info;
unsigned long gid = packet->get<unsigned long>("gid");
if(gid)
- info = application->getUserManager()->getGroupInfo(gid);
+ info = application->getUserManager()->getGroupInfo(gid, &timestamp);
else
- info = application->getUserManager()->getGroupInfoByName(packet->get<const std::string&>("name"));
+ info = application->getUserManager()->getGroupInfoByName(packet->get<const std::string&>("name"), &timestamp);
ret->setType("OK");
- ret->set("gid", info->getGid());
- ret->set("name", info->getName());
+ if(!timestamp.is_not_a_date_time())
+ ret->set("timestamp", boost::posix_time::to_iso_string(timestamp));
+
+ if(info) {
+ ret->set("gid", info->getGid());
+ ret->set("name", info->getName());
+ }
}
void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<const std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid"));
+ boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
+
+ const std::string &timestr = packet->get<const std::string&>("timestamp");
+ if(!timestr.empty()) {
+ try {
+ timestamp = boost::posix_time::from_iso_string(timestr);
+ }
+ catch(...) {}
+ }
+
+ boost::shared_ptr<const std::set<unsigned long> > users = application->getUserManager()->getGroupUserList(packet->get<unsigned long>("gid"), &timestamp);
ret->setType("OK");
+
+ if(!timestamp.is_not_a_date_time())
+ ret->set("timestamp", boost::posix_time::to_iso_string(timestamp));
+
Common::XmlPacket::List *list = ret->createList("users");
for(std::set<unsigned long>::const_iterator user = users->begin(); user != users->end(); ++user) {
@@ -119,18 +216,34 @@ void UserRequestHandlerGroup::handleGroupUserListRequest(boost::shared_ptr<const
}
}
-void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet _UNUSED_PARAMETER_, Common::XmlPacket *ret,
+void UserRequestHandlerGroup::handleFullUserGroupListRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret,
Common::Connection *connection _UNUSED_PARAMETER_) {
- boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > userGroups = application->getUserManager()->getFullUserGroupList();
+ boost::posix_time::ptime timestamp(boost::posix_time::not_a_date_time);
+
+ const std::string &timestr = packet->get<const std::string&>("timestamp");
+ if(!timestr.empty()) {
+ try {
+ timestamp = boost::posix_time::from_iso_string(timestr);
+ }
+ catch(...) {}
+ }
+
+ boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > userGroups = application->getUserManager()->getFullUserGroupList(&timestamp);
ret->setType("OK");
- Common::XmlPacket::List *list = ret->createList("userGroupList");
- for(std::map<unsigned long, unsigned long>::const_iterator userGroup = userGroups->begin(); userGroup != userGroups->end(); ++userGroup) {
- Common::XmlPacket::List::iterator entry = list->addEntry();
+ if(!timestamp.is_not_a_date_time())
+ ret->set("timestamp", boost::posix_time::to_iso_string(timestamp));
+
+ if(userGroups) {
+ Common::XmlPacket::List *list = ret->createList("userGroupList");
+
+ for(std::map<unsigned long, unsigned long>::const_iterator userGroup = userGroups->begin(); userGroup != userGroups->end(); ++userGroup) {
+ Common::XmlPacket::List::iterator entry = list->addEntry();
- entry->set("uid", userGroup->first);
- entry->set("gid", userGroup->second);
+ entry->set("uid", userGroup->first);
+ entry->set("gid", userGroup->second);
+ }
}
}