00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef MESSAGESESSION_H__
00015 #define MESSAGESESSION_H__
00016
00017 #include "jid.h"
00018
00019 #include <string>
00020 #include <list>
00021
00022 namespace gloox
00023 {
00024
00025 class ClientBase;
00026 class Tag;
00027 class MessageFilter;
00028 class MessageHandler;
00029 class Stanza;
00030
00146 class GLOOX_API MessageSession
00147 {
00148
00149 friend class MessageFilter;
00150
00151 public:
00168 MessageSession( ClientBase *parent, const JID& jid, bool wantUpgrade = true, int types = 0 );
00169
00176 virtual ~MessageSession();
00177
00182 const JID& target() const { return m_target; }
00183
00189 const std::string& threadID() const { return m_thread; }
00190
00197 void registerMessageHandler( MessageHandler *mh );
00198
00203 void removeMessageHandler();
00204
00211 virtual void send( const std::string& message, const std::string& subject = "" );
00212
00221 void registerMessageFilter( MessageFilter *mf );
00222
00228 void removeMessageFilter( MessageFilter *mf );
00229
00235 void disposeMessageFilter( MessageFilter *mf );
00236
00242 int types() const { return m_types; }
00243
00251 void resetResource();
00252
00253
00254 virtual void handleMessage( Stanza *stanza );
00255
00256 protected:
00263 virtual void send( Tag *tag );
00264 void decorate( Tag *tag );
00265
00266 ClientBase *m_parent;
00267 JID m_target;
00268 MessageHandler *m_messageHandler;
00269
00270 private:
00271 void setResource( const std::string& resource );
00272
00273 typedef std::list<MessageFilter*> MessageFilterList;
00274 MessageFilterList m_messageFilterList;
00275
00276 std::string m_thread;
00277 int m_types;
00278 bool m_wantUpgrade;
00279 bool m_hadMessages;
00280
00281 };
00282
00283 }
00284
00285 #endif // MESSAGESESSION_H__