+namespace
+{
+ std::string SerializeCaps(const Extensible* container, void* item, bool human)
+ {
+ // XXX: Cast away the const because IS_LOCAL() doesn't handle it
+ LocalUser* user = IS_LOCAL(const_cast<User*>(static_cast<const User*>(container)));
+ if (!user)
+ return std::string();
+
+ // List requested caps
+ std::vector<std::string> result;
+ managerimpl->HandleList(result, user, false, false);
+
+ // Serialize cap protocol version. If building a human-readable string append a
+ // new token, otherwise append only a single character indicating the version.
+ std::string version;
+ if (human)
+ version.append("capversion=3.");
+ switch (managerimpl->GetProtocol(user))
+ {
+ case Cap::CAP_302:
+ version.push_back('2');
+ break;
+ default:
+ version.push_back('1');
+ break;
+ }
+ result.push_back(version);
+
+ return stdalgo::string::join(result, ' ');
+ }
+}
+