summaryrefslogtreecommitdiffstats
path: root/src/Common/Backends
diff options
context:
space:
mode:
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, 50 insertions, 0 deletions
diff --git a/src/Common/Backends/NetworkUserBackend.cpp b/src/Common/Backends/NetworkUserBackend.cpp
index 1e06a78..6296581 100644
--- a/src/Common/Backends/NetworkUserBackend.cpp
+++ b/src/Common/Backends/NetworkUserBackend.cpp
@@ -83,6 +83,15 @@ void NetworkUserBackend::UserUpdateRequest::sendRequest() {
sendPacket(packet);
}
+void NetworkUserBackend::UserGroupRequest::sendRequest() {
+ XmlPacket packet;
+ packet.setType(type);
+ packet.set("uid", uid);
+ packet.set("gid", gid);
+
+ sendPacket(packet);
+}
+
boost::shared_ptr<const std::map<unsigned long, UserInfo> > NetworkUserBackend::getUserList(boost::posix_time::ptime *timestamp) throw(Core::Exception) {
application->getThreadManager()->detach();
@@ -406,6 +415,30 @@ void NetworkUserBackend::deleteUser(unsigned long uid) throw(Core::Exception) {
throw result.second;
}
+void NetworkUserBackend::addUserToGroup(unsigned long uid, unsigned long gid) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
+ boost::shared_ptr<UserGroupRequest> request(new UserGroupRequest(application, "AddUserToGroup", uid, gid));
+ 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::deleteUserFromGroup(unsigned long uid, unsigned long gid) throw(Core::Exception) {
+ application->getThreadManager()->detach();
+
+ boost::shared_ptr<UserGroupRequest> request(new UserGroupRequest(application, "DeleteUserFromGroup", uid, gid));
+ 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 b932e87..0567514 100644
--- a/src/Common/Backends/NetworkUserBackend.h
+++ b/src/Common/Backends/NetworkUserBackend.h
@@ -96,6 +96,20 @@ class NetworkUserBackend : public UserBackend {
: Request(application), uid(uid0), userInfo(userInfo0) {}
};
+ class UserGroupRequest : public Request {
+ private:
+ std::string type;
+ unsigned long uid;
+ unsigned long gid;
+
+ protected:
+ virtual void sendRequest();
+
+ public:
+ UserGroupRequest(Application *application, const std::string &type0, unsigned long uid0, unsigned long gid0)
+ : Request(application), type(type0), uid(uid0), gid(gid0) {}
+ };
+
Application *application;
Connection *connection;
@@ -118,6 +132,9 @@ class NetworkUserBackend : public UserBackend {
virtual void updateUser(unsigned long uid, const Common::UserInfo &userInfo) throw(Core::Exception);
virtual void deleteUser(unsigned long uid) throw(Core::Exception);
+ virtual void addUserToGroup(unsigned long uid, unsigned long gid) throw(Core::Exception);
+ virtual void deleteUserFromGroup(unsigned long uid, unsigned long gid) throw(Core::Exception);
+
public:
NetworkUserBackend(Application *application0, Connection *connection0) : application(application0), connection(connection0) {}
};