summaryrefslogtreecommitdiffstats
path: root/src/Common/Backends
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-07-10 02:08:03 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-07-10 02:08:03 +0200
commitf892ec46086eee9c4bfb954469016829fb201532 (patch)
treec6abb16ea1b52953a37da995dc988c823685a46a /src/Common/Backends
parent5bf8b6ce656ffe0740ec116057577044e3925887 (diff)
downloadmad-f892ec46086eee9c4bfb954469016829fb201532.tar
mad-f892ec46086eee9c4bfb954469016829fb201532.zip
updateUser und deleteUser zum UserBackendMysql, NetworkUserBackend und Client hinzugefügt
Diffstat (limited to 'src/Common/Backends')
-rw-r--r--src/Common/Backends/NetworkUserBackend.cpp33
-rw-r--r--src/Common/Backends/NetworkUserBackend.h17
2 files changed, 49 insertions, 1 deletions
diff --git a/src/Common/Backends/NetworkUserBackend.cpp b/src/Common/Backends/NetworkUserBackend.cpp
index 7e77253..20deba6 100644
--- a/src/Common/Backends/NetworkUserBackend.cpp
+++ b/src/Common/Backends/NetworkUserBackend.cpp
@@ -70,6 +70,19 @@ void NetworkUserBackend::UserAddRequest::sendRequest() {
sendPacket(packet);
}
+void NetworkUserBackend::UserUpdateRequest::sendRequest() {
+ XmlPacket packet;
+ packet.setType("UpdateUser");
+
+ packet.set("origUid", uid);
+ packet.set("uid", userInfo.getUid());
+ packet.set("gid", userInfo.getGid());
+ packet.set("username", userInfo.getUsername());
+ packet.set("fullName", userInfo.getFullName());
+
+ sendPacket(packet);
+}
+
boost::shared_ptr<const std::map<unsigned long, UserInfo> > NetworkUserBackend::getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
boost::shared_ptr<SimpleUserRequest> request(new SimpleUserRequest(application, "ListUsers", timestamp));
application->getRequestManager()->sendRequest(connection, request);
@@ -349,6 +362,26 @@ void NetworkUserBackend::addUser(const UserInfo &userInfo) throw(Core::Exception
throw result.second;
}
+void NetworkUserBackend::updateUser(unsigned long uid, const Common::UserInfo &userInfo) throw(Core::Exception) {
+ boost::shared_ptr<UserUpdateRequest> request(new UserUpdateRequest(application, uid, userInfo));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+}
+
+void NetworkUserBackend::deleteUser(unsigned long uid) throw(Core::Exception) {
+ boost::shared_ptr<IdUserRequest> request(new IdUserRequest(application, "DeleteUser", "uid", uid));
+ application->getRequestManager()->sendRequest(connection, request);
+ request->wait();
+
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> result = request->getResult();
+ if(!result.first || result.second)
+ throw result.second;
+}
+
}
}
}
diff --git a/src/Common/Backends/NetworkUserBackend.h b/src/Common/Backends/NetworkUserBackend.h
index 939c3b1..b932e87 100644
--- a/src/Common/Backends/NetworkUserBackend.h
+++ b/src/Common/Backends/NetworkUserBackend.h
@@ -53,7 +53,7 @@ class NetworkUserBackend : public UserBackend {
virtual void sendRequest();
public:
- IdUserRequest(Application *application, const std::string &type0, const std::string &idType0, unsigned long id0, boost::posix_time::ptime *timestamp0)
+ IdUserRequest(Application *application, const std::string &type0, const std::string &idType0, unsigned long id0, boost::posix_time::ptime *timestamp0 = 0)
: Request(application), type(type0), idType(idType0), id(id0), timestamp(timestamp0 ? *timestamp0 : boost::posix_time::not_a_date_time) {}
};
@@ -83,6 +83,19 @@ class NetworkUserBackend : public UserBackend {
: Request(application), userInfo(userInfo0) {}
};
+ class UserUpdateRequest : public Request {
+ private:
+ unsigned long uid;
+ UserInfo userInfo;
+
+ protected:
+ virtual void sendRequest();
+
+ public:
+ UserUpdateRequest(Application *application, unsigned long uid0, const UserInfo &userInfo0)
+ : Request(application), uid(uid0), userInfo(userInfo0) {}
+ };
+
Application *application;
Connection *connection;
@@ -102,6 +115,8 @@ class NetworkUserBackend : public UserBackend {
//virtual void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception);
virtual void addUser(const UserInfo &userInfo) throw(Core::Exception);
+ virtual void updateUser(unsigned long uid, const Common::UserInfo &userInfo) throw(Core::Exception);
+ virtual void deleteUser(unsigned long uid) throw(Core::Exception);
public:
NetworkUserBackend(Application *application0, Connection *connection0) : application(application0), connection(connection0) {}