mucmessagesession.cpp

00001 /*
00002   Copyright (c) 2006-2008 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 #include "mucmessagesession.h"
00015 #include "clientbase.h"
00016 #include "stanza.h"
00017 #include "messagehandler.h"
00018 
00019 namespace gloox
00020 {
00021 
00022   MUCMessageSession::MUCMessageSession( ClientBase *parent, const JID& jid )
00023     : MessageSession( parent, jid, false, StanzaMessageGroupchat | StanzaMessageChat
00024                                           | StanzaMessageNormal | StanzaMessageError )
00025   {
00026   }
00027 
00028   MUCMessageSession::~MUCMessageSession()
00029   {
00030   }
00031 
00032   void MUCMessageSession::handleMessage( Stanza *stanza )
00033   {
00034     if( m_messageHandler )
00035       m_messageHandler->handleMessage( stanza );
00036   }
00037 
00038   void MUCMessageSession::send( const std::string& message )
00039   {
00040     Tag *m = new Tag( "message" );
00041     m->addAttribute( "type", "groupchat" );
00042     new Tag( m, "body", message );
00043 
00044     m->addAttribute( "from", m_parent->jid().full() );
00045     m->addAttribute( "to", m_target.full() );
00046 
00047 //     decorate( m );
00048 
00049     m_parent->send( m );
00050   }
00051 
00052   void MUCMessageSession::setSubject( const std::string& subject )
00053   {
00054     Tag *m = new Tag( "message" );
00055     m->addAttribute( "to", m_target.bare() );
00056     m->addAttribute( "type", "groupchat" );
00057     new Tag( m, "subject", subject );
00058 
00059     m_parent->send( m );
00060   }
00061 
00062 }

Generated on Sun Apr 27 11:08:13 2008 for gloox by  doxygen 1.5.5