16 #include "stanzaextension.h"
17 #include "stanzaextensionfactory.h"
24 Stanza::Stanza(
const std::string& name,
const std::string& cdata,
const std::string& xmllang,
28 m_stanzaErrorAppCondition( 0 ), m_xmllang( xmllang ), m_priority( -300 )
35 m_stanzaErrorAppCondition( 0 ), m_xmllang(
"default" )
39 Tag::TagList::const_iterator it = l.begin();
40 for( ; it != l.end(); ++it )
50 StanzaExtensionList::iterator it = m_extensionList.begin();
51 for( ; it != m_extensionList.end(); ++it )
82 TagList::const_iterator it = c.begin();
83 for( ; it != c.end(); ++it )
87 m_extensionList.push_back( se );
90 else if( m_name ==
"message" )
105 TagList::const_iterator it = c.begin();
106 for( ; it != c.end(); ++it )
108 if( (*it)->name() ==
"body" )
110 setLang( m_body, (*it) );
112 else if( (*it)->name() ==
"subject" )
114 setLang( m_subject, (*it) );
116 else if( (*it)->name() ==
"thread" )
118 m_thread = (*it)->cdata();
124 m_extensionList.push_back( se );
128 else if( m_name ==
"presence" )
205 TagList::const_iterator it = c.begin();
206 for( ; it != c.end(); ++it )
208 if( (*it)->name() ==
"status" )
210 setLang( m_status, (*it) );
216 m_extensionList.push_back( se );
227 if( e->hasAttribute(
"type",
"cancel" ) )
229 else if( e->hasAttribute(
"type",
"continue" ) )
231 else if( e->hasAttribute(
"type",
"modify" ) )
233 else if( e->hasAttribute(
"type",
"auth" ) )
235 else if( e->hasAttribute(
"type",
"wait" ) )
238 const TagList& c = e->children();
239 TagList::const_iterator it = c.begin();
241 for( ; it != c.end(); ++it )
243 if( (*it)->name() ==
"bad-request" )
245 else if( (*it)->name() ==
"conflict" )
247 else if( (*it)->name() ==
"feature-not-implemented" )
249 else if( (*it)->name() ==
"forbidden" )
251 else if( (*it)->name() ==
"gone" )
253 else if( (*it)->name() ==
"internal-server-error" )
255 else if( (*it)->name() ==
"item-not-found" )
257 else if( (*it)->name() ==
"jid-malformed" )
259 else if( (*it)->name() ==
"not-acceptable" )
261 else if( (*it)->name() ==
"not-allowed" )
263 else if( (*it)->name() ==
"not-authorized" )
265 else if( (*it)->name() ==
"recipient-unavailable" )
267 else if( (*it)->name() ==
"redirect" )
269 else if( (*it)->name() ==
"registration-required" )
271 else if( (*it)->name() ==
"remote-server-not-found" )
273 else if( (*it)->name() ==
"remote-server-timeout" )
275 else if( (*it)->name() ==
"resource-constraint" )
277 else if( (*it)->name() ==
"service-unavailable" )
279 else if( (*it)->name() ==
"subscription-required" )
281 else if( (*it)->name() ==
"undefined-condition" )
283 else if( (*it)->name() ==
"unexpected-request" )
285 else if( (*it)->name() ==
"text" )
287 setLang( m_errorText, (*it) );
290 m_stanzaErrorAppCondition = (*it);
303 m_extensionList.push_back( se );
330 Tag *q =
new Tag( s,
"query" );
344 Presence status,
const std::string& xmllang )
353 new Tag( s,
"show",
"chat" );
356 new Tag( s,
"show",
"away" );
359 new Tag( s,
"show",
"dnd" );
362 new Tag( s,
"show",
"xa" );
373 Tag *t =
new Tag( s,
"status", msg );
384 const std::string& thread,
const std::string& xmllang )
411 Tag *b =
new Tag( s,
"body", body );
414 if( !subject.empty() )
416 Tag *su =
new Tag( s,
"subject", subject );
419 if( !thread.empty() )
420 new Tag( s,
"thread", thread );
451 Tag *t =
new Tag( s,
"status", msg );
463 map[ lang.empty() ?
"default" : lang ] = tag->
cdata();
466 const std::string Stanza::findLang(
const StringMap& map,
const std::string& lang )
468 StringMap::const_iterator it = map.find( lang );
469 return ( it != map.end() ) ? (*it).second : std::string();