diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-03-27 01:37:37 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-03-27 01:37:37 +0100 |
commit | c6f8a170e642b5b1a28bd85857f715846bbadbb4 (patch) | |
tree | ff254204358a62ca9da4f2f433370c802f059a33 /src/Client/CommandParser.cpp | |
parent | 3a219dd11cd05284b8b97f7016c671f0df4a0706 (diff) | |
download | mad-c6f8a170e642b5b1a28bd85857f715846bbadbb4.tar mad-c6f8a170e642b5b1a28bd85857f715846bbadbb4.zip |
userInfo() im Mysql-Backend implementiert; UserInfo-Request hinzugefuegt
Diffstat (limited to 'src/Client/CommandParser.cpp')
-rw-r--r-- | src/Client/CommandParser.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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 <Common/Requests/FSInfoRequest.h> #include <Common/Requests/DisconnectRequest.h> #include <Common/Requests/StatusRequest.h> +#include <Common/Requests/UserInfoRequest.h> #include <Common/Requests/UserListRequest.h> #include <Common/Tokenizer.h> @@ -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<std::string> &args) { ++CommandManager::get()->activeRequests; } +void CommandParser::userInfoCommand(const std::vector<std::string> &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<Common::Requests::UserInfoRequest>(connection, + sigc::mem_fun(CommandManager::get(), &CommandManager::userInfoRequestFinished), uid); +} + void CommandParser::listUsersCommand(const std::vector<std::string>&) { ++CommandManager::get()->activeRequests; |