messagesession.h

00001 /*
00002   Copyright (c) 2005-2007 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 
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       // re-implemented from MessageHandler
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__

Generated on Sat Nov 10 08:50:27 2007 for gloox by  doxygen 1.5.3-20071008