diff options
Diffstat (limited to 'src/Client/CommandManager.cpp')
-rw-r--r-- | src/Client/CommandManager.cpp | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/Client/CommandManager.cpp b/src/Client/CommandManager.cpp index b427db7..603f679 100644 --- a/src/Client/CommandManager.cpp +++ b/src/Client/CommandManager.cpp @@ -235,7 +235,7 @@ void CommandManager::userListRequestFinished(const Common::Request &request) { std::cout << "User list is empty." << std::endl; } else { - std::cout << "Found " << users.getSize() << " users:" << std::endl; + std::cout << "Found " << users.getSize() << " user" << (users.getSize()==1 ? "" : "s") << ":" << std::endl; for(size_t i = 0; i < users.getSize(); ++i) @@ -251,6 +251,33 @@ void CommandManager::userListRequestFinished(const Common::Request &request) { requestFinished(); } +void CommandManager::userGroupListRequestFinished(const Common::Request &request) { + try { + const Common::XmlPacket &packet = request.getResult(); + + const Common::XmlPacket::Element &groups = packet["groups"]; + + if(groups.isEmpty()) { + std::cout << "The user isn't member of any group." << std::endl; + } + else { + + std::cout << "User is member of " << groups.getSize() << " group" << (groups.getSize()==1 ? "" : "s") << ":" << std::endl; + + + for(size_t i = 0; i < groups.getSize(); ++i) + std::cout << " " << (unsigned long)groups[i]["gid"] << 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(); +} + void CommandManager::groupListRequestFinished(const Common::Request &request) { try { const Common::XmlPacket &packet = request.getResult(); @@ -261,7 +288,7 @@ void CommandManager::groupListRequestFinished(const Common::Request &request) { std::cout << "Group list is empty." << std::endl; } else { - std::cout << "Found " << groups.getSize() << " groups:" << std::endl; + std::cout << "Found " << groups.getSize() << " group" << (groups.getSize()==1 ? "" : "s") << ":" << std::endl; for(size_t i = 0; i < groups.getSize(); ++i) @@ -277,5 +304,32 @@ void CommandManager::groupListRequestFinished(const Common::Request &request) { requestFinished(); } +void CommandManager::groupUserListRequestFinished(const Common::Request &request) { + try { + const Common::XmlPacket &packet = request.getResult(); + + const Common::XmlPacket::Element &users = packet["users"]; + + if(users.isEmpty()) { + std::cout << "The group doesn't have any members." << std::endl; + } + else { + + std::cout << "The group has " << users.getSize() << " member" << (users.getSize()==1 ? "" : "s") << ":" << std::endl; + + + for(size_t i = 0; i < users.getSize(); ++i) + std::cout << " " << (unsigned long)users[i]["uid"] << 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(); +} + } } |