/** * Handle portions of messages containing custom stanza extensions. */ bool XmppClient::handleIq(const glooxwrapper::IQ& iq) { DbgXMPP("handleIq [" << tag_xml(iq) << "]"); if(iq.subtype() == gloox::IQ::Result) { const GameListQuery* gq = iq.findExtension<GameListQuery>( ExtGameListQuery ); const BoardListQuery* bq = iq.findExtension<BoardListQuery>( ExtBoardListQuery ); if(gq) { for(std::vector<const glooxwrapper::Tag*>::const_iterator it = m_GameList.begin(); it != m_GameList.end(); ++it ) glooxwrapper::Tag::free(*it); m_GameList.clear(); for(std::vector<const glooxwrapper::Tag*>::const_iterator it = gq->m_GameList.begin(); it != gq->m_GameList.end(); ++it) m_GameList.push_back( (*it)->clone() ); CreateSimpleMessage("system", "gamelist updated", "internal"); } if(bq) { if (bq->m_Command == "boardlist") { for(std::vector<const glooxwrapper::Tag*>::const_iterator it = m_BoardList.begin(); it != m_BoardList.end(); ++it ) glooxwrapper::Tag::free(*it); m_BoardList.clear(); for(std::vector<const glooxwrapper::Tag*>::const_iterator it = bq->m_StanzaBoardList.begin(); it != bq->m_StanzaBoardList.end(); ++it) m_BoardList.push_back((*it)->clone()); CreateSimpleMessage("system", "boardlist updated", "internal"); } else if (bq->m_Command == "ratinglist") { for(std::vector<const glooxwrapper::Tag*>::const_iterator it = bq->m_StanzaBoardList.begin(); it != bq->m_StanzaBoardList.end(); ++it) { std::string name = (*it)->findAttribute("name").to_string(); if (m_PlayerMap.find(name) != m_PlayerMap.end()) m_PlayerMap[name][1] = (*it)->findAttribute("rating").to_string(); } CreateSimpleMessage("system", "ratinglist updated", "internal"); } } } else if(iq.subtype() == gloox::IQ::Error) { gloox::StanzaError err = iq.error_error(); std::string msg = StanzaErrorToString(err); CreateSimpleMessage("system", msg, "error"); } else { CreateSimpleMessage("system", std::string("unknown subtype : ") + tag_name(iq), "error"); } return true; }
/** * Handle MUC room errors */ void XmppClient::handleMUCError(glooxwrapper::MUCRoom*, gloox::StanzaError err) { std::string msg = StanzaErrorToString(err); CreateSimpleMessage("system", msg, "error"); }