diff --git a/src/discoinforesponder.cpp b/src/discoinforesponder.cpp index 91f6b494b5a37800ebf64e06ff9f8255be1c7055..15ce154426eb36b669ae6aefe1a01d6ffc8d8f49 100644 --- a/src/discoinforesponder.cpp +++ b/src/discoinforesponder.cpp @@ -39,11 +39,12 @@ namespace Transport { DiscoInfoResponder::DiscoInfoResponder(Swift::IQRouter *router, Config *config) : Swift::GetResponder(router) { m_config = config; + m_config->onBackendConfigUpdated.connect(boost::bind(&DiscoInfoResponder::updateBuddyFeatures, this)); + m_buddyInfo = NULL; m_transportInfo.addIdentity(DiscoInfo::Identity(CONFIG_STRING(m_config, "identity.name"), CONFIG_STRING(m_config, "identity.category"), CONFIG_STRING(m_config, "identity.type"))); - m_buddyInfo.addIdentity(DiscoInfo::Identity(CONFIG_STRING(m_config, "identity.name"), "client", "pc")); std::list features; features.push_back("jabber:iq:register"); features.push_back("jabber:iq:gateway"); @@ -52,18 +53,25 @@ DiscoInfoResponder::DiscoInfoResponder(Swift::IQRouter *router, Config *config) features.push_back("http://jabber.org/protocol/commands"); setTransportFeatures(features); - features.clear(); + updateBuddyFeatures(); +} + +DiscoInfoResponder::~DiscoInfoResponder() { + delete m_buddyInfo; +} + +void DiscoInfoResponder::updateBuddyFeatures() { + std::list features; features.push_back("http://jabber.org/protocol/disco#items"); features.push_back("http://jabber.org/protocol/disco#info"); features.push_back("http://jabber.org/protocol/chatstates"); features.push_back("http://jabber.org/protocol/xhtml-im"); + if (CONFIG_BOOL_DEFAULTED(m_config, "features.receipts", false)) { + features.push_back("urn:xmpp:receipts"); + } setBuddyFeatures(features); } -DiscoInfoResponder::~DiscoInfoResponder() { - -} - void DiscoInfoResponder::setTransportFeatures(std::list &features) { for (std::list::iterator it = features.begin(); it != features.end(); it++) { if (!m_transportInfo.hasFeature(*it)) { @@ -73,14 +81,18 @@ void DiscoInfoResponder::setTransportFeatures(std::list &features) } void DiscoInfoResponder::setBuddyFeatures(std::list &f) { + delete m_buddyInfo; + m_buddyInfo = new Swift::DiscoInfo; + m_buddyInfo->addIdentity(DiscoInfo::Identity(CONFIG_STRING(m_config, "identity.name"), "client", "pc")); + for (std::list::iterator it = f.begin(); it != f.end(); it++) { - if (!m_buddyInfo.hasFeature(*it)) { - m_buddyInfo.addFeature(*it); + if (!m_buddyInfo->hasFeature(*it)) { + m_buddyInfo->addFeature(*it); } } CapsInfoGenerator caps("spectrum"); - m_capsInfo = caps.generateCapsInfo(m_buddyInfo); + m_capsInfo = caps.generateCapsInfo(*m_buddyInfo); onBuddyCapsInfoChanged(m_capsInfo); } @@ -136,7 +148,7 @@ bool DiscoInfoResponder::handleGetRequest(const Swift::JID& from, const Swift::J } // disco#info for buddy else { - boost::shared_ptr res(new DiscoInfo(m_buddyInfo)); + boost::shared_ptr res(new DiscoInfo(*m_buddyInfo)); res->setNode(info->getNode()); sendResponse(from, to, id, res); }