14 #include "messagesession.h"
16 #include "messagefilter.h"
17 #include "messagehandler.h"
18 #include "clientbase.h"
27 : m_parent( parent ), m_target( jid ), m_messageHandler( 0 ),
28 m_types( types ), m_wantUpgrade( wantUpgrade ), m_hadMessages( false )
36 MessageFilterList::const_iterator it = m_messageFilterList.begin();
37 for( ; it != m_messageFilterList.end(); ++it )
41 void MessageSession::handleMessage(
Stanza *stanza )
43 if( m_wantUpgrade && stanza->
from().
bare() == m_target.
full() )
49 if( stanza->
thread().empty() )
51 m_thread =
"gloox" + m_parent->
getID();
55 m_thread = stanza->
thread();
58 MessageFilterList::const_iterator it = m_messageFilterList.begin();
59 for( ; it != m_messageFilterList.end(); ++it )
61 (*it)->filter( stanza );
64 if( m_messageHandler && !stanza->
body().empty() )
72 m_thread =
"gloox" + m_parent->
getID();
76 Tag *m =
new Tag(
"message" );
78 new Tag( m,
"body", message );
79 if( !subject.empty() )
80 new Tag( m,
"subject", subject );
85 new Tag( m,
"thread", m_thread );
94 m_parent->
send( tag );
97 void MessageSession::decorate(
Tag *tag )
99 MessageFilterList::const_iterator it = m_messageFilterList.begin();
100 for( ; it != m_messageFilterList.end(); ++it )
102 (*it)->decorate( tag );
108 m_wantUpgrade =
true;
112 void MessageSession::setResource(
const std::string& resource )
119 m_messageHandler = mh;
124 m_messageHandler = 0;
129 m_messageFilterList.push_back( mf );
134 m_messageFilterList.remove( mf );