std::string Buddy::JIDToLegacyName(const Swift::JID &jid) { std::string name; if (jid.getUnescapedNode() == jid.getNode()) { name = jid.getNode(); if (name.find_last_of("%") != std::string::npos) { name.replace(name.find_last_of("%"), 1, "@"); // OK } } else { name = jid.getUnescapedNode(); // Psi sucks... // if (name.find_last_of("\\40") != std::string::npos) { // name.replace(name.find_last_of("\\40"), 1, "@"); // OK // } } return name; }
bool DiscoItemsResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::DiscoItems> info) { LOG4CXX_INFO(logger, "get request received with node " << info->getNode()); if (info->getNode() == "http://jabber.org/protocol/commands") { sendResponse(from, id, m_commands); } else if (to.getNode().empty()) { sendResponse(from, id, m_rooms); } else { sendResponse(from, id, boost::shared_ptr<DiscoItems>(new DiscoItems())); } return true; }
bool DiscoInfoResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::DiscoInfo> info) { // disco#info for transport if (to.getNode().empty()) { // Adhoc command if (m_commands.find(info->getNode()) != m_commands.end()) { boost::shared_ptr<DiscoInfo> res(new DiscoInfo()); res->addFeature("http://jabber.org/protocol/commands"); res->addFeature("jabber:x:data"); res->addIdentity(DiscoInfo::Identity(m_commands[info->getNode()], "automation", "command-node")); res->setNode(info->getNode()); sendResponse(from, to, id, res); } else if (info->getNode() == "http://jabber.org/protocol/commands") { boost::shared_ptr<DiscoInfo> res(new DiscoInfo()); res->addIdentity(DiscoInfo::Identity("Commands", "automation", "command-list")); res->setNode(info->getNode()); sendResponse(from, to, id, res); } else { if (!info->getNode().empty()) { sendError(from, id, ErrorPayload::ItemNotFound, ErrorPayload::Cancel); return true; } boost::shared_ptr<DiscoInfo> res(new DiscoInfo(m_transportInfo)); res->setNode(info->getNode()); sendResponse(from, id, res); } } // disco#info for room else if (m_rooms.find(to.toBare().toString()) != m_rooms.end()) { boost::shared_ptr<DiscoInfo> res(new DiscoInfo()); res->addIdentity(DiscoInfo::Identity(m_rooms[to.toBare().toString()], "conference", "text")); res->addFeature("http://jabber.org/protocol/muc"); res->setNode(info->getNode()); sendResponse(from, to, id, res); } // disco#info for buddy else { boost::shared_ptr<DiscoInfo> res(new DiscoInfo(*m_buddyInfo)); res->setNode(info->getNode()); sendResponse(from, to, id, res); } return true; }
bool DiscoItemsResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoItems> info) { LOG4CXX_INFO(logger, "get request received with node " << info->getNode()); if (info->getNode() == "http://jabber.org/protocol/commands") { sendResponse(from, id, m_commands); } else if (to.getNode().empty() && info->getNode().empty()) { XMPPUser *user = static_cast<XMPPUser *>(m_userManager->getUser(from.toBare().toString())); if (!user) { sendResponse(from, id, m_rooms); return true; } SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<DiscoItems> rooms = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<DiscoItems>(new DiscoItems()); BOOST_FOREACH(const DiscoItems::Item &item, m_rooms->getItems()) { rooms->addItem(item); } BOOST_FOREACH(const DiscoItems::Item &item, user->getRoomList()->getItems()) { rooms->addItem(item); } sendResponse(from, id, rooms); }
BuddyFlag Buddy::buddFlagsFromJID(const Swift::JID &jid) { if (jid.getUnescapedNode() == jid.getNode()) { return BUDDY_NO_FLAG; } return BUDDY_JID_ESCAPING; }