gloox
1.0
|
00001 /* 00002 Copyright (c) 2005-2009 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 #ifndef MESSAGESESSION_H__ 00015 #define MESSAGESESSION_H__ 00016 00017 #include "jid.h" 00018 #include "gloox.h" 00019 00020 #include <string> 00021 #include <list> 00022 00023 namespace gloox 00024 { 00025 00026 class ClientBase; 00027 class MessageFilter; 00028 class MessageHandler; 00029 class Message; 00030 00145 class GLOOX_API MessageSession 00146 { 00147 00148 friend class MessageFilter; 00149 00150 public: 00168 MessageSession( ClientBase* parent, const JID& jid, bool wantUpgrade = true, int types = 0, bool honorTID = true ); 00169 00176 virtual ~MessageSession(); 00177 00182 const JID& target() const { return m_target; } 00183 00189 const std::string& threadID() const { return m_thread; } 00190 00196 void setThreadID( const std::string& thread ) { m_thread = thread; } 00197 00203 bool honorThreadID() const { return m_honorThreadID; } 00204 00211 void registerMessageHandler( MessageHandler* mh ) 00212 { m_messageHandler = mh; } 00213 00218 void removeMessageHandler() 00219 { m_messageHandler = 0; } 00220 00229 virtual void send( const std::string& message, const std::string& subject = EmptyString, 00230 const StanzaExtensionList& sel = StanzaExtensionList() ); 00231 00240 void registerMessageFilter( MessageFilter* mf ) 00241 { m_messageFilterList.push_back( mf ); } 00242 00248 void removeMessageFilter( MessageFilter* mf ) 00249 { m_messageFilterList.remove( mf ); } 00250 00256 void disposeMessageFilter( MessageFilter* mf ); 00257 00262 int types() const { return m_types; } 00263 00270 void resetResource(); 00271 00277 virtual void handleMessage( Message& msg ); 00278 00279 protected: 00286 virtual void send( const Message& msg ); 00287 void decorate( Message& msg ); 00288 00289 ClientBase* m_parent; 00290 JID m_target; 00291 MessageHandler* m_messageHandler; 00292 00293 private: 00294 void setResource( const std::string& resource ); 00295 00296 typedef std::list<MessageFilter*> MessageFilterList; 00297 MessageFilterList m_messageFilterList; 00298 00299 std::string m_thread; 00300 int m_types; 00301 bool m_wantUpgrade; 00302 bool m_hadMessages; 00303 bool m_honorThreadID; 00304 00305 }; 00306 00307 } 00308 00309 #endif // MESSAGESESSION_H__