15 #include "discohandler.h"
16 #include "clientbase.h"
17 #include "disconodehandler.h"
23 Disco::Disco( ClientBase *parent )
60 Tag *query =
new Tag( iq,
"query" );
62 new Tag( query,
"name", m_versionName );
63 new Tag( query,
"version", m_versionVersion );
64 new Tag( query,
"os", m_versionOs );
75 Tag *query =
new Tag( iq,
"query" );
85 DiscoNodeHandlerMap::const_iterator it = m_nodeHandlers.find( node );
86 if( it != m_nodeHandlers.end() )
89 DiscoNodeHandlerList::const_iterator in = (*it).second.begin();
90 for( ; in != (*it).second.end(); ++in )
92 const StringMap& identities = (*in)->handleDiscoNodeIdentities( node, name );
93 StringMap::const_iterator im = identities.begin();
94 for( ; im != identities.end(); ++im )
96 Tag *i =
new Tag( query,
"identity" );
102 StringList::const_iterator fi = features.begin();
103 for( ; fi != features.end(); ++fi )
105 Tag *f =
new Tag( query,
"feature" );
113 Tag *i =
new Tag( query,
"identity" );
118 StringList::const_iterator it = m_features.begin();
119 for( ; it != m_features.end(); ++it )
121 Tag *f =
new Tag( query,
"feature" );
126 m_parent->
send( iq );
130 Tag *iq =
new Tag(
"iq" );
135 Tag *query =
new Tag( iq,
"query" );
138 DiscoNodeHandlerMap::const_iterator it;
142 it = m_nodeHandlers.find( node );
143 if( it != m_nodeHandlers.end() )
145 DiscoNodeHandlerList::const_iterator in = (*it).second.begin();
146 for( ; in != (*it).second.end(); ++in )
149 DiscoNodeItemList::const_iterator it = items.begin();
150 for( ; it != items.end(); ++it )
152 Tag *i =
new Tag( query,
"item" );
160 m_parent->
send( iq );
168 DiscoHandlerList::const_iterator it = m_discoHandlers.begin();
169 for( ; it != m_discoHandlers.end(); ++it )
171 if( (*it)->handleDiscoSet( stanza ) )
186 DiscoHandlerMap::iterator it = m_track.find( stanza->
id() );
187 if( it != m_track.end() )
195 (*it).second.dh->handleDiscoInfoResult( stanza, (*it).second.context );
197 case GET_DISCO_ITEMS:
198 (*it).second.dh->handleDiscoItemsResult( stanza, (*it).second.context );
204 (*it).second.dh->handleDiscoError( stanza, (*it).second.context );
219 m_features.push_back( feature );
224 m_features.remove( feature );
228 const std::string& tid )
230 const std::string&
id = tid.empty() ? m_parent->
getID() : tid;
232 Tag *iq =
new Tag(
"iq" );
237 Tag *q =
new Tag( iq,
"query" );
242 DiscoHandlerContext ct;
244 ct.context = context;
246 m_parent->
trackID(
this,
id, GET_DISCO_INFO );
247 m_parent->
send( iq );
251 const std::string& tid )
253 const std::string&
id = tid.empty() ? m_parent->
getID() : tid;
255 Tag *iq =
new Tag(
"iq" );
260 Tag *q =
new Tag( iq,
"query" );
265 DiscoHandlerContext ct;
267 ct.context = context;
269 m_parent->
trackID(
this,
id, GET_DISCO_ITEMS );
270 m_parent->
send( iq );
273 void Disco::setVersion(
const std::string& name,
const std::string& version,
const std::string& os )
275 m_versionName = name;
276 m_versionVersion = version;
282 m_identityCategory = category;
283 m_identityType = type;
288 m_discoHandlers.push_back( dh );
293 m_discoHandlers.remove( dh );
294 DiscoHandlerMap::iterator t;
295 DiscoHandlerMap::iterator it = m_track.begin();
296 while( it != m_track.end() )
300 if( dh == (*t).second.dh )
309 m_nodeHandlers[node].push_back( nh );
314 DiscoNodeHandlerMap::iterator it = m_nodeHandlers.find( node );
315 if( it != m_nodeHandlers.end() )
317 (*it).second.remove( nh );
318 if( !(*it).second.size() )
320 m_nodeHandlers.erase( it );