Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

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 #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 
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         { m_messageHandler = mh; }
00206 
00211       void removeMessageHandler()
00212         { m_messageHandler = 0; }
00213 
00220       virtual void send( const std::string& message, const std::string& subject = EmptyString );
00221 
00230       void registerMessageFilter( MessageFilter* mf )
00231         { m_messageFilterList.push_back( mf ); }
00232 
00238       void removeMessageFilter( MessageFilter* mf )
00239         { m_messageFilterList.remove( mf ); }
00240 
00246       void disposeMessageFilter( MessageFilter* mf );
00247 
00252       int types() const { return m_types; }
00253 
00260       void resetResource();
00261 
00267       virtual void handleMessage( Message& msg );
00268 
00269     protected:
00276       virtual void send( const Message& msg );
00277       void decorate( Message& msg );
00278 
00279       ClientBase* m_parent;
00280       JID m_target;
00281       MessageHandler* m_messageHandler;
00282 
00283     private:
00284       void setResource( const std::string& resource );
00285 
00286       typedef std::list<MessageFilter*> MessageFilterList;
00287       MessageFilterList m_messageFilterList;
00288 
00289       std::string m_thread;
00290       int m_types;
00291       bool m_wantUpgrade;
00292       bool m_hadMessages;
00293 
00294   };
00295 
00296 }
00297 
00298 #endif // MESSAGESESSION_H__

Generated on Mon Jun 23 10:50:18 2008 for gloox by  doxygen 1.4.1