diff options
Diffstat (limited to 'src/Client')
-rw-r--r-- | src/Client/CommandManager.cpp | 26 | ||||
-rw-r--r-- | src/Client/CommandManager.h | 1 | ||||
-rw-r--r-- | src/Client/CommandParser.cpp | 9 | ||||
-rw-r--r-- | src/Client/CommandParser.h | 1 |
4 files changed, 37 insertions, 0 deletions
diff --git a/src/Client/CommandManager.cpp b/src/Client/CommandManager.cpp index f46bdcd..b427db7 100644 --- a/src/Client/CommandManager.cpp +++ b/src/Client/CommandManager.cpp @@ -251,5 +251,31 @@ void CommandManager::userListRequestFinished(const Common::Request &request) { requestFinished(); } +void CommandManager::groupListRequestFinished(const Common::Request &request) { + try { + const Common::XmlPacket &packet = request.getResult(); + + const Common::XmlPacket::Element &groups = packet["groups"]; + + if(groups.isEmpty()) { + std::cout << "Group list is empty." << std::endl; + } + else { + std::cout << "Found " << groups.getSize() << " groups:" << std::endl; + + + for(size_t i = 0; i < groups.getSize(); ++i) + std::cout << " " << (unsigned long)groups[i]["gid"] << ", " << (const std::string&)groups[i]["name"] << std::endl; + } + + std::cout << std::endl; + } + catch(Net::Exception &exception) { + Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", exception.strerror().c_str()); + } + + requestFinished(); +} + } } diff --git a/src/Client/CommandManager.h b/src/Client/CommandManager.h index 7635542..3cfc502 100644 --- a/src/Client/CommandManager.h +++ b/src/Client/CommandManager.h @@ -60,6 +60,7 @@ class CommandManager { void statusRequestFinished(const Common::Request &request); void userInfoRequestFinished(const Common::Request &request); void userListRequestFinished(const Common::Request &request); + void groupListRequestFinished(const Common::Request &request); CommandManager() : activeRequests(0), disconnect(false) {} diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index 78b3570..044a64c 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -26,6 +26,7 @@ #include <Common/RequestManager.h> #include <Common/Requests/FSInfoRequest.h> #include <Common/Requests/DisconnectRequest.h> +#include <Common/Requests/GroupListRequest.h> #include <Common/Requests/StatusRequest.h> #include <Common/Requests/UserInfoRequest.h> #include <Common/Requests/UserListRequest.h> @@ -48,6 +49,7 @@ const CommandParser::Command CommandParser::commands[] = { {{"status", "st", 0}, "status [host]", "Display status information", "Display host status information. If no host is given, display server status information.", &CommandParser::statusCommand}, {{"user_info", "user", 0}, "user_info uid", "Search for a user id", "Search for a user id.", &CommandParser::userInfoCommand}, {{"list_users", "users", 0}, "list_users", "Show the user account database", "Show the user account database.", &CommandParser::listUsersCommand}, + {{"list_groups", "groups", 0}, "list_groups", "Show the user group database", "Show the user group database.", &CommandParser::listGroupsCommand}, {{"exit", "quit", 0}, "exit", "Close the connection and quit the client", "Closes the connection and quits the client.", &CommandParser::exitCommand}, {{0}, 0, 0, 0, 0} }; @@ -290,6 +292,13 @@ void CommandParser::listUsersCommand(const std::vector<std::string>&) { boost::bind(&CommandManager::userListRequestFinished, CommandManager::get(), _1)); } +void CommandParser::listGroupsCommand(const std::vector<std::string>&) { + ++CommandManager::get()->activeRequests; + + Common::RequestManager::get()->sendRequest<Common::Requests::GroupListRequest>(connection, + boost::bind(&CommandManager::groupListRequestFinished, CommandManager::get(), _1)); +} + void CommandParser::exitCommand(const std::vector<std::string>&) { ++CommandManager::get()->activeRequests; diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h index 4b44656..727181e 100644 --- a/src/Client/CommandParser.h +++ b/src/Client/CommandParser.h @@ -65,6 +65,7 @@ class CommandParser { void statusCommand(const std::vector<std::string> &args); void userInfoCommand(const std::vector<std::string> &args); void listUsersCommand(const std::vector<std::string> &args); + void listGroupsCommand(const std::vector<std::string> &args); void exitCommand(const std::vector<std::string>&); CommandParser() : connection(0) {} |