From f892ec46086eee9c4bfb954469016829fb201532 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 10 Jul 2009 02:08:03 +0200 Subject: =?UTF-8?q?updateUser=20und=20deleteUser=20zum=20UserBackendMysql,?= =?UTF-8?q?=20NetworkUserBackend=20und=20Client=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/Backends/NetworkUserBackend.cpp | 33 ++++++++++++++++++++++++++++++ src/Common/Backends/NetworkUserBackend.h | 17 ++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) (limited to 'src/Common/Backends') 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 > NetworkUserBackend::getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception) { boost::shared_ptr 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 request(new UserUpdateRequest(application, uid, userInfo)); + application->getRequestManager()->sendRequest(connection, request); + request->wait(); + + std::pair, 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 request(new IdUserRequest(application, "DeleteUser", "uid", uid)); + application->getRequestManager()->sendRequest(connection, request); + request->wait(); + + std::pair, 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) {} -- cgit v1.2.3