14 #include "capabilities.h"
22 static const char* msgTypeStringValues[] =
24 "available",
"",
"",
"",
"",
"unavailable",
"probe",
"error"
29 return util::lookup( type, msgTypeStringValues );
32 static const char* msgShowStringValues[] =
34 "",
"chat",
"away",
"dnd",
"xa",
"",
"",
""
39 return util::lookup( type, msgShowStringValues );
43 : Stanza( tag ), m_subtype( Invalid ), m_stati( 0 ), m_priority( 0 )
45 if( !tag || tag->name() !=
"presence" )
48 const std::string& type = tag->findAttribute(
TYPE );
50 m_subtype = Available;
52 m_subtype = (PresenceType)util::lookup( type, msgTypeStringValues );
54 if( m_subtype == Available )
56 Tag* t = tag->findChild(
"show" );
58 m_subtype = (PresenceType)util::lookup( t->cdata(), msgShowStringValues );
61 const TagList& c = tag->children();
62 TagList::const_iterator it = c.begin();
63 for( ; it != c.end(); ++it )
65 if( (*it)->name() ==
"status" )
66 setLang( &m_stati, m_status, (*it) );
67 else if( (*it)->name() ==
"priority" )
68 m_priority = atoi( (*it)->cdata().c_str() );
73 int priority,
const std::string& xmllang )
74 :
Stanza( to ), m_subtype( type ), m_stati( 0 )
76 setLang( &m_stati, m_status, status, xmllang );
97 else if( priority > 127 )
105 return findExtension<Capabilities>(
ExtCaps );
113 Tag* t =
new Tag(
"presence" );
119 const std::string& type = typeString( m_subtype );
122 if( type !=
"available" )
127 const std::string& show = showString( m_subtype );
129 new Tag( t,
"show", show );
132 new Tag( t,
"priority", util::int2string( m_priority ) );
134 getLangs( m_stati, m_status,
"status", t );
136 StanzaExtensionList::const_iterator it = m_extensionList.begin();
137 for( ; it != m_extensionList.end(); ++it )