messagesession.h

00001 /*
00002   Copyright (c) 2005-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 #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 
00196       void setThreadID( const std::string& thread ) { m_thread = thread; }
00197 
00204       void registerMessageHandler( MessageHandler *mh );
00205 
00210       void removeMessageHandler();
00211 
00218       virtual void send( const std::string& message, const std::string& subject = "" );
00219 
00228       void registerMessageFilter( MessageFilter *mf );
00229 
00235       void removeMessageFilter( MessageFilter *mf );
00236 
00242       void disposeMessageFilter( MessageFilter *mf );
00243 
00249       int types() const { return m_types; }
00250 
00258       void resetResource();
00259 
00260       // re-implemented from MessageHandler
00261       virtual void handleMessage( Stanza *stanza );
00262 
00263     protected:
00270       virtual void send( Tag *tag );
00271       void decorate( Tag *tag );
00272 
00273       ClientBase *m_parent;
00274       JID m_target;
00275       MessageHandler *m_messageHandler;
00276 
00277     private:
00278       void setResource( const std::string& resource );
00279 
00280       typedef std::list<MessageFilter*> MessageFilterList;
00281       MessageFilterList m_messageFilterList;
00282 
00283       std::string m_thread;
00284       int m_types;
00285       bool m_wantUpgrade;
00286       bool m_hadMessages;
00287 
00288   };
00289 
00290 }
00291 
00292 #endif // MESSAGESESSION_H__

Generated on Fri Oct 10 15:26:11 2008 for gloox by  doxygen 1.5.6