gloox  1.0.27
mucmessagesession.cpp
1 /*
2  Copyright (c) 2006-2023 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #include "mucmessagesession.h"
15 #include "clientbase.h"
16 #include "message.h"
17 #include "messagehandler.h"
18 
19 namespace gloox
20 {
21 
23  : MessageSession( parent, jid, false, Message::Groupchat | Message::Chat
24  | Message::Normal | Message::Error,
25  false )
26  {
27  }
28 
30  {
31  }
32 
34  {
35  if( m_messageHandler )
36  m_messageHandler->handleMessage( msg );
37  }
38 
39  void MUCMessageSession::send( const std::string& message )
40  {
41  send( message, EmptyString );
42  }
43 
44  void MUCMessageSession::send( const std::string& message, const std::string& subject, const StanzaExtensionList& sel )
45  {
46  if( !m_hadMessages )
47  {
48  m_thread = "gloox" + m_parent->getID();
49  m_hadMessages = true;
50  }
51 
52  Message m( Message::Groupchat, m_target.bare(), message, subject, m_thread );
53  m.setID( m_parent->getID() );
54  decorate( m );
55 
56  if( sel.size() )
57  {
58  StanzaExtensionList::const_iterator it = sel.begin();
59  for( ; it != sel.end(); ++it )
60  m.addExtension( (*it));
61  }
62 
64  }
65 
66  void MUCMessageSession::setSubject( const std::string& subject )
67  {
68  Message m( Message::Groupchat, m_target.bareJID(), EmptyString, subject );
69  m_parent->send( m );
70  }
71 
72 }
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:79
const std::string getID()
void send(Tag *tag)
A stanza error abstraction implemented as a StanzaExtension.
Definition: error.h:35
An abstraction of a JID.
Definition: jid.h:31
const std::string & bare() const
Definition: jid.h:67
JID bareJID() const
Definition: jid.h:74
virtual void send(const std::string &message)
MUCMessageSession(ClientBase *parent, const JID &jid)
virtual void setSubject(const std::string &subject)
virtual void handleMessage(Message &msg)
virtual void handleMessage(const Message &msg, MessageSession *session=0)=0
An abstraction of a message session between any two entities.
virtual void send(const std::string &message)
An abstraction of a message stanza.
Definition: message.h:34
void setID(const std::string &id)
Definition: message.h:122
void addExtension(const StanzaExtension *se)
Definition: stanza.cpp:52
The namespace for the gloox library.
Definition: adhoc.cpp:28
std::list< const StanzaExtension * > StanzaExtensionList
Definition: gloox.h:1268
const std::string EmptyString
Definition: gloox.cpp:124