diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-06-18 22:03:02 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-06-18 22:03:02 +0200 |
commit | 7234fe326d16d6bf9f4374a09ddc6ef790e6723f (patch) | |
tree | 437d4c40eeb1e9b34b369e4b82064a1572c7dac9 /src/Client/UserCommands.cpp | |
parent | bf561f8226e97f4ace4f04bddf198175e91ee7f0 (diff) | |
download | mad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.tar mad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.zip |
Globale Variablen durch Application-Klasse ersetzt
Diffstat (limited to 'src/Client/UserCommands.cpp')
-rw-r--r-- | src/Client/UserCommands.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/Client/UserCommands.cpp b/src/Client/UserCommands.cpp index 97ea27b..a1cfd0f 100644 --- a/src/Client/UserCommands.cpp +++ b/src/Client/UserCommands.cpp @@ -18,9 +18,9 @@ */ #include "UserCommands.h" +#include "Application.h" #include "CommandParser.h" -#include <Core/Logger.h> #include <Common/RequestManager.h> #include <Common/Requests/GroupListRequest.h> @@ -35,34 +35,34 @@ namespace Mad { namespace Client { -void UserCommands::userInfoCommand(const std::vector<std::string> &args, Common::Connection *connection) { +void UserCommands::userInfoCommand(CommandParser *commandParser, const std::vector<std::string> &args) { if(args.size() == 1) { - Core::Logger::logf(Core::Logger::ERROR, "%s: No user id given.", args[0].c_str()); - CommandParser::printUsage("user_info"); + std::cerr << args[0] << ": No user id given." << std::endl; + commandParser->printUsage("user_info"); return; } if(args.size() > 2) { - Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); - CommandParser::printUsage("user_info"); + std::cerr << args[0] << ": Too many arguments." << std::endl; + commandParser->printUsage("user_info"); return; } char *endptr; unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); if(args[1].empty() || *endptr != '\0') { - Core::Logger::logf(Core::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str()); - CommandParser::printUsage("user_info"); + std::cerr << args[0] << ": Unable to parse user id." << std::endl; + commandParser->printUsage("user_info"); return; } - boost::shared_ptr<Common::Requests::UserInfoRequest> request(new Common::Requests::UserInfoRequest(uid)); - Common::RequestManager::get()->sendRequest(connection, request); + boost::shared_ptr<Common::Requests::UserInfoRequest> request(new Common::Requests::UserInfoRequest(commandParser->application, uid)); + commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request); request->wait(); std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult(); if(!result.first || result.second) { - Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str()); + std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl; } else { const Common::XmlPacket &packet = *result.first; @@ -72,16 +72,16 @@ void UserCommands::userInfoCommand(const std::vector<std::string> &args, Common: } } -void UserCommands::listUsersCommand(const std::vector<std::string> &args _UNUSED_PARAMETER_, Common::Connection *connection) { - boost::shared_ptr<Common::Requests::UserListRequest> request(new Common::Requests::UserListRequest); +void UserCommands::listUsersCommand(CommandParser *commandParser, const std::vector<std::string> &args _UNUSED_PARAMETER_) { + boost::shared_ptr<Common::Requests::UserListRequest> request(new Common::Requests::UserListRequest(commandParser->application)); - Common::RequestManager::get()->sendRequest(connection, request); + commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request); request->wait(); std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult(); if(!result.first || result.second) { - Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str()); + std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl; } else { const Common::XmlPacket::Element &users = (*result.first)["users"]; @@ -101,34 +101,34 @@ void UserCommands::listUsersCommand(const std::vector<std::string> &args _UNUSED } } -void UserCommands::listUserGroupsCommand(const std::vector<std::string> &args, Common::Connection *connection) { +void UserCommands::listUserGroupsCommand(CommandParser *commandParser, const std::vector<std::string> &args) { if(args.size() == 1) { - Core::Logger::logf(Core::Logger::ERROR, "%s: No user id given.", args[0].c_str()); - CommandParser::printUsage("list_user_groups"); + std::cerr << args[0] << ": No user id given." << std::endl; + commandParser->printUsage("list_user_groups"); return; } if(args.size() > 2) { - Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); - CommandParser::printUsage("list_user_groups"); + std::cerr << args[0] << ": Too many arguments." << std::endl; + commandParser->printUsage("list_user_groups"); return; } char *endptr; unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10); if(args[1].empty() || *endptr != '\0') { - Core::Logger::logf(Core::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str()); - CommandParser::printUsage("list_user_groups"); + std::cerr << args[0] << ": Unable to parse user id." << std::endl; + commandParser->printUsage("list_user_groups"); return; } - boost::shared_ptr<Common::Requests::UserGroupListRequest> request(new Common::Requests::UserGroupListRequest(uid)); - Common::RequestManager::get()->sendRequest(connection, request); + boost::shared_ptr<Common::Requests::UserGroupListRequest> request(new Common::Requests::UserGroupListRequest(commandParser->application, uid)); + commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request); request->wait(); std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult(); if(!result.first || result.second) { - Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str()); + std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl; } else { const Common::XmlPacket::Element &groups = (*result.first)["groups"]; @@ -149,16 +149,16 @@ void UserCommands::listUserGroupsCommand(const std::vector<std::string> &args, C } } -void UserCommands::listGroupsCommand(const std::vector<std::string> &args _UNUSED_PARAMETER_, Common::Connection *connection) { - boost::shared_ptr<Common::Requests::GroupListRequest> request(new Common::Requests::GroupListRequest); +void UserCommands::listGroupsCommand(CommandParser *commandParser, const std::vector<std::string> &args _UNUSED_PARAMETER_) { + boost::shared_ptr<Common::Requests::GroupListRequest> request(new Common::Requests::GroupListRequest(commandParser->application)); - Common::RequestManager::get()->sendRequest(connection, request); + commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request); request->wait(); std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult(); if(!result.first || result.second) { - Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str()); + std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl; } else { const Common::XmlPacket::Element &groups = (*result.first)["groups"]; @@ -178,34 +178,34 @@ void UserCommands::listGroupsCommand(const std::vector<std::string> &args _UNUSE } } -void UserCommands::listGroupUsersCommand(const std::vector<std::string> &args, Common::Connection *connection) { +void UserCommands::listGroupUsersCommand(CommandParser *commandParser, const std::vector<std::string> &args) { if(args.size() == 1) { - Core::Logger::logf(Core::Logger::ERROR, "%s: No group id given.", args[0].c_str()); - CommandParser::printUsage("list_group_users"); + std::cerr << args[0] << ": No group id given." << std::endl; + commandParser->printUsage("list_group_users"); return; } if(args.size() > 2) { - Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); - CommandParser::printUsage("list_group_users"); + std::cerr << args[0] << ": Too many arguments." << std::endl; + commandParser->printUsage("list_group_users"); return; } char *endptr; unsigned long gid = std::strtoul(args[1].c_str(), &endptr, 10); if(args[1].empty() || *endptr != '\0') { - Core::Logger::logf(Core::Logger::ERROR, "%s: Unable to parse group id.", args[0].c_str()); - CommandParser::printUsage("list_group_users"); + std::cerr << args[0] << ": Unable to parse group id." << std::endl; + commandParser->printUsage("list_group_users"); return; } - boost::shared_ptr<Common::Requests::GroupUserListRequest> request(new Common::Requests::GroupUserListRequest(gid)); - Common::RequestManager::get()->sendRequest(connection, request); + boost::shared_ptr<Common::Requests::GroupUserListRequest> request(new Common::Requests::GroupUserListRequest(commandParser->application, gid)); + commandParser->application->getRequestManager()->sendRequest(commandParser->connection, request); request->wait(); std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult(); if(!result.first || result.second) { - Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str()); + std::cerr << "An error occurred during your request: " << result.second.strerror() << "." << std::endl; } else { const Common::XmlPacket::Element &users = (*result.first)["users"]; |