summaryrefslogtreecommitdiffstats
path: root/src/Core/RequestHandlers
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-02-13 00:00:05 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-02-13 00:00:05 +0100
commit04363ca342914ba75e693edb876cbe535839fa79 (patch)
treed1309d7b0f6288a8250e972e5cab2546f2a77609 /src/Core/RequestHandlers
parent2ab1fbd763ad8692ea3ca29705a4fe821ccb1309 (diff)
downloadmad-04363ca342914ba75e693edb876cbe535839fa79.tar
mad-04363ca342914ba75e693edb876cbe535839fa79.zip
Einfache Abfrage der Benutzerdatenbank implementiert
Diffstat (limited to 'src/Core/RequestHandlers')
-rw-r--r--src/Core/RequestHandlers/Makefile.am4
-rw-r--r--src/Core/RequestHandlers/Makefile.in17
-rw-r--r--src/Core/RequestHandlers/UserListRequestHandler.cpp63
-rw-r--r--src/Core/RequestHandlers/UserListRequestHandler.h51
4 files changed, 126 insertions, 9 deletions
diff --git a/src/Core/RequestHandlers/Makefile.am b/src/Core/RequestHandlers/Makefile.am
index 79aef5e..5a044c8 100644
--- a/src/Core/RequestHandlers/Makefile.am
+++ b/src/Core/RequestHandlers/Makefile.am
@@ -1,6 +1,6 @@
noinst_LTLIBRARIES = librequesthandlers.la
librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp \
- IdentifyRequestHandler.cpp LogRequestHandler.cpp
+ IdentifyRequestHandler.cpp LogRequestHandler.cpp UserListRequestHandler.cpp
noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h \
- IdentifyRequestHandler.h LogRequestHandler.h
+ IdentifyRequestHandler.h LogRequestHandler.h UserListRequestHandler.h
diff --git a/src/Core/RequestHandlers/Makefile.in b/src/Core/RequestHandlers/Makefile.in
index 980ffd4..18076c0 100644
--- a/src/Core/RequestHandlers/Makefile.in
+++ b/src/Core/RequestHandlers/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -53,7 +53,8 @@ librequesthandlers_la_LIBADD =
am_librequesthandlers_la_OBJECTS = DaemonCommandRequestHandler.lo \
DaemonFSInfoRequestHandler.lo DaemonListRequestHandler.lo \
DaemonStatusRequestHandler.lo GSSAPIAuthRequestHandler.lo \
- IdentifyRequestHandler.lo LogRequestHandler.lo
+ IdentifyRequestHandler.lo LogRequestHandler.lo \
+ UserListRequestHandler.lo
librequesthandlers_la_OBJECTS = $(am_librequesthandlers_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -213,14 +214,15 @@ srcdir = @srcdir@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_LTLIBRARIES = librequesthandlers.la
librequesthandlers_la_SOURCES = DaemonCommandRequestHandler.cpp DaemonFSInfoRequestHandler.cpp DaemonListRequestHandler.cpp DaemonStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp \
- IdentifyRequestHandler.cpp LogRequestHandler.cpp
+ IdentifyRequestHandler.cpp LogRequestHandler.cpp UserListRequestHandler.cpp
noinst_HEADERS = DaemonCommandRequestHandler.h DaemonFSInfoRequestHandler.h DaemonListRequestHandler.h DaemonStatusRequestHandler.h GSSAPIAuthRequestHandler.h \
- IdentifyRequestHandler.h LogRequestHandler.h
+ IdentifyRequestHandler.h LogRequestHandler.h UserListRequestHandler.h
all: all-am
@@ -230,8 +232,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
- && exit 0; \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
@@ -280,6 +282,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IdentifyRequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogRequestHandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserListRequestHandler.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -313,7 +316,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
diff --git a/src/Core/RequestHandlers/UserListRequestHandler.cpp b/src/Core/RequestHandlers/UserListRequestHandler.cpp
new file mode 100644
index 0000000..01c2eb3
--- /dev/null
+++ b/src/Core/RequestHandlers/UserListRequestHandler.cpp
@@ -0,0 +1,63 @@
+/*
+ * UserListRequestHandler.cpp
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "UserListRequestHandler.h"
+#include "../UserBackend.h"
+#include <Common/Logger.h>
+#include <Net/Connection.h>
+#include <Net/Packets/ErrorPacket.h>
+#include <Net/Packets/UserListPacket.h>
+
+namespace Mad {
+namespace Core {
+namespace RequestHandlers {
+
+void UserListRequestHandler::handlePacket(Net::Connection *con, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::USERS_LIST) {
+ Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
+ connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
+
+ signalFinished().emit();
+ return;
+ }
+
+ // TODO Require authentication
+
+ connection = con;
+ requestId = packet.getRequestId();
+
+ if(!UserBackend::getUserList(sigc::mem_fun(this, &UserListRequestHandler::userListHandler))) {
+ con->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::NOT_IMPLEMENTED)));
+ signalFinished().emit();
+ }
+}
+
+void UserListRequestHandler::userListHandler(const std::map<unsigned long, Common::UserInfo> &info) {
+ std::vector<Common::UserInfo> userList;
+
+ for(std::map<unsigned long, Common::UserInfo>::const_iterator user = info.begin(); user != info.end(); ++user)
+ userList.push_back(user->second);
+
+ connection->send(Net::Packets::UserListPacket(Net::Packet::OK, requestId, userList));
+ signalFinished().emit();
+}
+
+}
+}
+}
diff --git a/src/Core/RequestHandlers/UserListRequestHandler.h b/src/Core/RequestHandlers/UserListRequestHandler.h
new file mode 100644
index 0000000..92eddb7
--- /dev/null
+++ b/src/Core/RequestHandlers/UserListRequestHandler.h
@@ -0,0 +1,51 @@
+/*
+ * UserListRequestHandler.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_CORE_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_
+#define MAD_CORE_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_
+
+#include <Common/RequestHandler.h>
+#include <Common/UserInfo.h>
+
+#include <map>
+#include <stdint.h>
+
+namespace Mad {
+namespace Core {
+namespace RequestHandlers {
+
+class UserListRequestHandler : public Common::RequestHandler {
+ private:
+ Net::Connection *connection;
+ uint16_t requestId;
+
+ void userListHandler(const std::map<unsigned long, Common::UserInfo> &info);
+
+ protected:
+ virtual void handlePacket(Net::Connection *con, const Net::Packet &packet);
+
+ public:
+ UserListRequestHandler() {}
+};
+
+}
+}
+}
+
+#endif /* MAD_CORE_REQUESTHANDLERS_USERLISTREQUESTHANDLER_H_ */