00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00140 virtual const std::string& filterString() const;
00141
00142
00143 virtual StanzaExtension* newInstance( const Tag* tag ) const
00144 {
00145 return new Jingle( tag );
00146 }
00147
00148
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
00214 virtual bool handleIq( const IQ& iq );
00215
00216
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__