From c6f8a170e642b5b1a28bd85857f715846bbadbb4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 27 Mar 2009 01:37:37 +0100 Subject: userInfo() im Mysql-Backend implementiert; UserInfo-Request hinzugefuegt --- src/Client/CommandParser.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/Client/CommandParser.cpp') diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index 7e3a90e..8e55c01 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,7 @@ const CommandParser::Command CommandParser::commands[] = { {{"reboot", 0}, "reboot *|host...", "Reboot host", "Reboot hosts. * will reboot all hosts.", &CommandParser::rebootCommand}, {{"shutdown", "halt", 0}, "shutdown *|host...", "Shut hosts down", "Shut hosts down. * will shut down all hosts.", &CommandParser::shutdownCommand}, {{"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}, {{"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} @@ -255,6 +257,32 @@ void CommandParser::statusCommand(const std::vector &args) { ++CommandManager::get()->activeRequests; } +void CommandParser::userInfoCommand(const std::vector &args) { + if(args.size() == 1) { + Common::Logger::logf(Common::Logger::ERROR, "%s: No user id given.", args[0].c_str()); + printUsage("user_info"); + return; + } + if(args.size() > 2) { + Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); + printUsage("user_info"); + return; + } + + char *endptr; + unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); + if(args[1].empty() || *endptr != '\0') { + Common::Logger::logf(Common::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str()); + printUsage("user_info"); + return; + } + + ++CommandManager::get()->activeRequests; + + Common::RequestManager::get()->sendRequest(connection, + sigc::mem_fun(CommandManager::get(), &CommandManager::userInfoRequestFinished), uid); +} + void CommandParser::listUsersCommand(const std::vector&) { ++CommandManager::get()->activeRequests; -- cgit v1.2.3