From 264cd7947d7291f78065f12824523ba6178a9936 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 22 May 2009 00:23:59 +0200 Subject: GroupListRequest hinzugef?gt --- src/Client/CommandManager.cpp | 26 ++++++++++++++++++++++++++ src/Client/CommandManager.h | 1 + src/Client/CommandParser.cpp | 9 +++++++++ src/Client/CommandParser.h | 1 + 4 files changed, 37 insertions(+) (limited to 'src/Client') 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 #include #include +#include #include #include #include @@ -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&) { boost::bind(&CommandManager::userListRequestFinished, CommandManager::get(), _1)); } +void CommandParser::listGroupsCommand(const std::vector&) { + ++CommandManager::get()->activeRequests; + + Common::RequestManager::get()->sendRequest(connection, + boost::bind(&CommandManager::groupListRequestFinished, CommandManager::get(), _1)); +} + void CommandParser::exitCommand(const std::vector&) { ++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 &args); void userInfoCommand(const std::vector &args); void listUsersCommand(const std::vector &args); + void listGroupsCommand(const std::vector &args); void exitCommand(const std::vector&); CommandParser() : connection(0) {} -- cgit v1.2.3