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-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 JINGLESESSION_H__
00015 #define JINGLESESSION_H__
00016 
00017 #include "stanzaextension.h"
00018 #include "tag.h"
00019 #include "iqhandler.h"
00020 
00021 #include <string>
00022 
00023 namespace gloox
00024 {
00025 
00026   class ClientBase;
00027 
00034   namespace Jingle
00035   {
00036 
00037     class Description;
00038     class Transport;
00039     class SessionHandler;
00040     class Content;
00041 
00045     typedef std::list<const Content*> ContentList;
00046 
00050     enum Action
00051     {
00052       ContentAccept,                
00053       ContentAdd,                   
00054       ContentModify,                
00055       ContentRemove,                
00056       ContentReplace,               
00057       SessionAccept,                
00058       SessionInfo,                  
00059       SessionInitiate,              
00060       SessionTerminate,             
00061       TransportInfo,                
00062       InvalidAction                 
00063     };
00064 
00076     class GLOOX_API Session : public IqHandler
00077     {
00078 
00079       public:
00083         enum State
00084         {
00085           Ended,                    
00086           Pending,                  
00087           Active                    
00088         };
00089 
00097         class Jingle : public StanzaExtension
00098         {
00099 
00100           friend class Session;
00101 
00102           public:
00107             Jingle( const Tag* tag = 0 );
00108 
00112             virtual ~Jingle();
00113 
00117             void addContent( const Content* content, Action action );
00118 
00122             const std::string& sid() const { return m_sid; }
00123 
00127             void setInitiator( const std::string& initiator ) { m_initiator = initiator; }
00128 
00132             void setResponder( const std::string& responder ) { m_responder = responder; }
00133 
00137             Action action() const { return m_action; }
00138 
00139             // reimplemented from StanzaExtension
00140             virtual const std::string& filterString() const;
00141 
00142             // reimplemented from StanzaExtension
00143             virtual StanzaExtension* newInstance( const Tag* tag ) const
00144             {
00145               return new Jingle( tag );
00146             }
00147 
00148             // reimplemented from StanzaExtension
00149             virtual Tag* tag() const;
00150 
00151 #ifdef JINGLE_TEST
00152           public:
00153 #else
00154           private:
00155 #endif
00156 
00160             Jingle( Action action, const ContentList& contents, const std::string& sid );
00161 
00165             Jingle( Action action, const Content* content, const std::string& sid );
00166 
00167             Action m_action;
00168             std::string m_sid;
00169             std::string m_initiator;
00170             std::string m_responder;
00171             ContentList m_contents;
00172 
00173         };
00174 
00177         Session( ClientBase* parent, const JID& callee, SessionHandler* jsh );
00178 
00182         virtual ~Session();
00183 
00187         bool initiate();
00188 
00192         bool terminate();
00193 
00197         State state() const { return m_state; }
00198 
00207         void addContent( Content* content )
00208         {
00209           if( content )
00210             m_contents.push_back( content );
00211         }
00212 
00213         // reimplemented from IqHandler
00214         virtual bool handleIq( const IQ& iq );
00215 
00216         // reimplemented from IqHandler
00217         virtual void handleIqID( const IQ& iq, int context );
00218 
00219 #ifdef JINGLE_TEST
00220       public:
00221 #else
00222       private:
00223 #endif
00224         ClientBase* m_parent;
00225         State m_state;
00226         JID m_callee;
00227         SessionHandler* m_handler;
00228         ContentList m_contents;
00229         std::string m_sid;
00230         bool m_valid;
00231 
00232     };
00233 
00234   }
00235 
00236 }
00237 
00238 #endif // JINGLESESSION_H__

Generated on Mon Sep 1 09:25:10 2008 for gloox by  doxygen 1.4.1