summaryrefslogtreecommitdiffstats
path: root/src/Common
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/Common
parent2ab1fbd763ad8692ea3ca29705a4fe821ccb1309 (diff)
downloadmad-04363ca342914ba75e693edb876cbe535839fa79.tar
mad-04363ca342914ba75e693edb876cbe535839fa79.zip
Einfache Abfrage der Benutzerdatenbank implementiert
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/ActionManager.cpp2
-rw-r--r--src/Common/Makefile.am2
-rw-r--r--src/Common/Makefile.in11
-rw-r--r--src/Common/ModuleManager.cpp2
-rw-r--r--src/Common/Request.h2
-rw-r--r--src/Common/RequestHandlers/Makefile.in9
-rw-r--r--src/Common/Requests/Makefile.am4
-rw-r--r--src/Common/Requests/Makefile.in16
-rw-r--r--src/Common/Requests/UserListRequest.cpp42
-rw-r--r--src/Common/Requests/UserListRequest.h43
-rw-r--r--src/Common/UserInfo.h55
11 files changed, 165 insertions, 23 deletions
diff --git a/src/Common/ActionManager.cpp b/src/Common/ActionManager.cpp
index c6c4e41..fc2bd98 100644
--- a/src/Common/ActionManager.cpp
+++ b/src/Common/ActionManager.cpp
@@ -23,7 +23,7 @@
#include <fcntl.h>
#include <signal.h>
-#include <sigc++/hide.h>
+#include <sigc++/adaptors/hide.h>
namespace Mad {
namespace Common {
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
index 0f2fb39..665c21a 100644
--- a/src/Common/Makefile.am
+++ b/src/Common/Makefile.am
@@ -9,4 +9,4 @@ libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandler
noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \
Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \
RemoteLogger.h Request.h RequestBase.h RequestHandler.h RequestManager.h \
- SystemBackend.h Tokenizer.h
+ SystemBackend.h Tokenizer.h UserInfo.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
index e787215..2fb869f 100644
--- a/src/Common/Makefile.in
+++ b/src/Common/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,
@@ -224,6 +224,7 @@ 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@
SUBDIRS = Requests RequestHandlers
@@ -236,7 +237,7 @@ libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers
noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \
Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \
RemoteLogger.h Request.h RequestBase.h RequestHandler.h RequestManager.h \
- SystemBackend.h Tokenizer.h
+ SystemBackend.h Tokenizer.h UserInfo.h
all: all-recursive
@@ -246,8 +247,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; \
@@ -403,7 +404,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/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp
index 06732a4..0e892c5 100644
--- a/src/Common/ModuleManager.cpp
+++ b/src/Common/ModuleManager.cpp
@@ -22,8 +22,6 @@
#include "ConfigEntry.h"
#include "Logger.h"
-#include <iostream>
-
extern const lt_dlsymlist lt_preloaded_symbols[];
diff --git a/src/Common/Request.h b/src/Common/Request.h
index 229b8b8..2317d5a 100644
--- a/src/Common/Request.h
+++ b/src/Common/Request.h
@@ -24,7 +24,7 @@
#include "Exception.h"
#include <memory>
-#include <sigc++/hide.h>
+#include <sigc++/adaptors/hide.h>
namespace Mad {
namespace Common {
diff --git a/src/Common/RequestHandlers/Makefile.in b/src/Common/RequestHandlers/Makefile.in
index 5b8b578..dc292e3 100644
--- a/src/Common/RequestHandlers/Makefile.in
+++ b/src/Common/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,
@@ -211,6 +211,7 @@ 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
@@ -224,8 +225,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; \
@@ -303,7 +304,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/Common/Requests/Makefile.am b/src/Common/Requests/Makefile.am
index ff116fc..eae8669 100644
--- a/src/Common/Requests/Makefile.am
+++ b/src/Common/Requests/Makefile.am
@@ -1,4 +1,4 @@
noinst_LTLIBRARIES = librequests.la
-librequests_la_SOURCES = DisconnectRequest.cpp FSInfoRequest.cpp GSSAPIAuthRequest.cpp StatusRequest.cpp
+librequests_la_SOURCES = DisconnectRequest.cpp FSInfoRequest.cpp GSSAPIAuthRequest.cpp StatusRequest.cpp UserListRequest.cpp
-noinst_HEADERS = DisconnectRequest.h FSInfoRequest.h GSSAPIAuthRequest.h StatusRequest.h
+noinst_HEADERS = DisconnectRequest.h FSInfoRequest.h GSSAPIAuthRequest.h StatusRequest.h UserListRequest.h
diff --git a/src/Common/Requests/Makefile.in b/src/Common/Requests/Makefile.in
index 631bb21..2c363eb 100644
--- a/src/Common/Requests/Makefile.in
+++ b/src/Common/Requests/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,
@@ -51,7 +51,7 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
librequests_la_LIBADD =
am_librequests_la_OBJECTS = DisconnectRequest.lo FSInfoRequest.lo \
- GSSAPIAuthRequest.lo StatusRequest.lo
+ GSSAPIAuthRequest.lo StatusRequest.lo UserListRequest.lo
librequests_la_OBJECTS = $(am_librequests_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -211,11 +211,12 @@ 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 = librequests.la
-librequests_la_SOURCES = DisconnectRequest.cpp FSInfoRequest.cpp GSSAPIAuthRequest.cpp StatusRequest.cpp
-noinst_HEADERS = DisconnectRequest.h FSInfoRequest.h GSSAPIAuthRequest.h StatusRequest.h
+librequests_la_SOURCES = DisconnectRequest.cpp FSInfoRequest.cpp GSSAPIAuthRequest.cpp StatusRequest.cpp UserListRequest.cpp
+noinst_HEADERS = DisconnectRequest.h FSInfoRequest.h GSSAPIAuthRequest.h StatusRequest.h UserListRequest.h
all: all-am
.SUFFIXES:
@@ -224,8 +225,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; \
@@ -271,6 +272,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FSInfoRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StatusRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserListRequest.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -304,7 +306,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/Common/Requests/UserListRequest.cpp b/src/Common/Requests/UserListRequest.cpp
new file mode 100644
index 0000000..cd9c760
--- /dev/null
+++ b/src/Common/Requests/UserListRequest.cpp
@@ -0,0 +1,42 @@
+/*
+ * UserListRequest.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 "UserListRequest.h"
+#include <Net/Connection.h>
+
+namespace Mad {
+namespace Common {
+namespace Requests {
+
+void UserListRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ connection->send(Net::Packet(Net::Packet::USERS_LIST, requestId));
+}
+
+void UserListRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::OK) {
+ finishWithError(Exception(Exception::UNEXPECTED_PACKET));
+ return; // TODO Logging
+ }
+
+ finish(Net::Packets::UserListPacket(packet));
+}
+
+}
+}
+}
diff --git a/src/Common/Requests/UserListRequest.h b/src/Common/Requests/UserListRequest.h
new file mode 100644
index 0000000..c62e284
--- /dev/null
+++ b/src/Common/Requests/UserListRequest.h
@@ -0,0 +1,43 @@
+/*
+ * UserListRequest.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_COMMON_REQUESTS_USERLISTREQUEST_H_
+#define MAD_COMMON_REQUESTS_USERLISTREQUEST_H_
+
+#include "../Request.h"
+#include <Net/Packets/UserListPacket.h>
+
+namespace Mad {
+namespace Common {
+namespace Requests {
+
+class UserListRequest : public Request<Net::Packets::UserListPacket> {
+ protected:
+ virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
+
+ public:
+ UserListRequest(slot_type slot) : Request<Net::Packets::UserListPacket>(slot) {}
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_REQUESTS_USERLISTREQUEST_H_ */
diff --git a/src/Common/UserInfo.h b/src/Common/UserInfo.h
new file mode 100644
index 0000000..94c0c60
--- /dev/null
+++ b/src/Common/UserInfo.h
@@ -0,0 +1,55 @@
+/*
+ * UserInfo.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_COMMON_USERINFO_H_
+#define MAD_COMMON_USERINFO_H_
+
+#include <string>
+
+namespace Mad {
+namespace Common {
+
+class UserInfo {
+ private:
+ unsigned long uid;
+ unsigned long gid;
+
+ std::string username;
+ std::string fullName;
+
+ public:
+ UserInfo(unsigned long uid0 = 0, const std::string& username0 = std::string()) : uid(uid0), gid(0), username(username0) {}
+
+ void setUid(unsigned long newUid) {uid = newUid;}
+ unsigned long getUid() const {return uid;}
+
+ void setGid(unsigned long newUid) {uid = newUid;}
+ unsigned long getGid() const {return uid;}
+
+ void setUsername(const std::string& newUsername) {username = newUsername;}
+ const std::string& getUsername() const {return username;}
+
+ void setFullName(const std::string& newFullName) {fullName = newFullName;}
+ const std::string& getFullName() const {return fullName;}
+};
+
+}
+}
+
+#endif /* MAD_COMMON_USERINFO_H_ */