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

jinglesession.h

00001 /*
00002   Copyright (c) 2007-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 JINGLESESSION_H__
00015 #define JINGLESESSION_H__
00016 
00017 #include "stanzaextension.h"
00018 #include "tag.h"
00019 #include "iqhandler.h"
00020 #include "jingleplugin.h"
00021 
00022 #include <string>
00023 
00024 namespace gloox
00025 {
00026 
00027   class ClientBase;
00028 
00038   namespace Jingle
00039   {
00040 
00041     class Description;
00042     class Transport;
00043     class SessionHandler;
00044     class Content;
00045 
00049     typedef std::list<const Plugin*> PluginList;
00050 
00054     enum Action
00055     {
00056       ContentAccept,                
00057       ContentAdd,                   
00058       ContentModify,                
00059       ContentReject,                
00060       ContentRemove,                
00061       DescriptionInfo,              
00062       SessionAccept,                
00063       SessionInfo,                  
00064       SessionInitiate,              
00065       SessionTerminate,             
00066       TransportAccept,              
00067       TransportInfo,                
00068       TransportReject,              
00069       TransportReplace,             
00070       InvalidAction                 
00071     };
00072 
00084     class GLOOX_API Session : public IqHandler
00085     {
00086 
00087       public:
00091         enum State
00092         {
00093           Ended,                    
00094           Pending,                  
00095           Active                    
00096         };
00097 
00105         class GLOOX_API Reason : public Plugin
00106         {
00107           public:
00111             enum Reasons
00112             {
00113               AlternativeSession,   
00114               Busy,                 
00115               Cancel,               
00116               ConnectivityError,    
00117               Decline,              
00118               Expired,              
00119               GeneralError,         
00120               Gone,                 
00121               MediaError,           
00122               SecurityError,        
00123               Success,              
00124               Timeout,              
00125               UnsupportedApplications,
00126               UnsupportedTransports,
00127               InvalidReason         
00128             };
00129 
00136             Reason( Reasons reason, const std::string& sid = EmptyString,
00137                     const std::string& text = EmptyString );
00138 
00143             Reason( const Tag* tag = 0 );
00144 
00148             virtual ~Reason() {}
00149 
00154             Reasons reason() const { return m_reason; }
00155 
00161             const std::string& sid() const { return m_sid; }
00162 
00168             const std::string& text() const { return m_text; }
00169 
00170             // reimplemented from Jingle::Plugin
00171             virtual const std::string& filterString() const;
00172 
00173             // reimplemented from Jingle::Plugin
00174             virtual Tag* tag() const;
00175 
00176             // reimplemented from Jingle::Plugin
00177             virtual Plugin* clone() const;
00178 
00179           private:
00180             Reasons m_reason;
00181             std::string m_sid;
00182             std::string m_text;
00183 
00184         };
00185 
00193         class Jingle : public StanzaExtension
00194         {
00195 
00196           friend class Session;
00197 
00198           public:
00203             Jingle( const Tag* tag = 0 );
00204 
00208             virtual ~Jingle();
00209 
00214             const std::string& sid() const { return m_sid; }
00215 
00219             void setInitiator( const JID& jid ) { m_initiator = jid; }
00220 
00225             const JID& initiator() const { return m_initiator; }
00226 
00230             void setResponder( const std::string& responder ) { m_responder = responder; }
00231 
00235             Action action() const { return m_action; }
00236 
00237             // reimplemented from StanzaExtension
00238             virtual const std::string& filterString() const;
00239 
00240             // reimplemented from StanzaExtension
00241             virtual StanzaExtension* newInstance( const Tag* tag ) const
00242             {
00243               return new Jingle( tag );
00244             }
00245 
00246             // reimplemented from StanzaExtension
00247             virtual Tag* tag() const;
00248 
00249             // reimplemented from StanzaExtension
00250             virtual StanzaExtension* clone() const;
00251 
00252 #ifdef JINGLE_TEST
00253           public:
00254 #else
00255           private:
00256 #endif
00257 
00265             Jingle( Action action, const JID& initiator,
00266                     const PluginList& plugins, const std::string& sid );
00267 
00276             Jingle( Action action, const JID& initiator,
00277                     const Plugin* plugin, const std::string& sid );
00278 
00283             Jingle( const Jingle& right );
00284 
00285             Action m_action;
00286             std::string m_sid;
00287             JID m_initiator;
00288             JID m_responder;
00289             PluginList m_plugins;
00290 
00291         };
00292 
00299         Session( ClientBase* parent, const JID& callee, SessionHandler* jsh );
00300 
00308         Session( ClientBase* parent, const Session::Jingle* jingle,
00309                  SessionHandler* jsh );
00310 
00314         virtual ~Session();
00315 
00321         bool initiate( const PluginList& plugins );
00322 
00329         bool accept( const Content* content );
00330 
00338         bool inform( Action action, const Plugin* plugin );
00339 
00345         bool terminate( Reason* reason );
00346 
00351         State state() const { return m_state; }
00352 
00357         const std::string& sid() const { return m_sid; }
00358 
00359         // reimplemented from IqHandler
00360         virtual bool handleIq( const IQ& iq );
00361 
00362         // reimplemented from IqHandler
00363         virtual void handleIqID( const IQ& iq, int context );
00364 
00365 #ifdef JINGLE_TEST
00366       public:
00367 #else
00368       private:
00369 #endif
00370         ClientBase* m_parent;
00371         State m_state;
00372         JID m_callee;
00373         JID m_initiator;
00374         SessionHandler* m_handler;
00375         std::string m_sid;
00376         bool m_valid;
00377 
00378     };
00379 
00380   }
00381 
00382 }
00383 
00384 #endif // JINGLESESSION_H__

Generated on Tue May 4 16:35:12 2010 for gloox by  doxygen 1.4.1