14 #include "jinglesession.h"
16 #include "clientbase.h"
18 #include "jinglecontent.h"
19 #include "jinglesessionhandler.h"
29 static const char* actionValues [] = {
47 static inline Action actionType(
const std::string& type )
49 return static_cast<Action>( util::lookup( type, actionValues ) );
53 static const char* reasonValues [] = {
54 "alternative-session",
64 "incompatible-parameters",
69 "unsupported-applications",
70 "unsupported-transports"
79 const std::string& sid,
80 const std::string& text)
92 TagList::const_iterator it = l.begin();
93 for( ; it != l.end(); ++it )
95 if( (*it)->name() ==
"text" )
96 m_text = (*it)->cdata();
98 m_reason = reasonType( (*it)->name() );
108 static const std::string filter =
"jingle/reason";
114 if( m_reason == InvalidReason )
117 Tag* t =
new Tag(
"reason" );
118 Tag* r =
new Tag( t, util::lookup( m_reason, reasonValues ) );
119 if( m_reason == AlternativeSession && !m_sid.empty() )
120 new Tag( r,
"sid", m_sid );
122 if( !m_text.empty() )
123 new Tag( t,
"text", m_text );
130 return new Reason( *
this );
144 const Plugin* plugin,
const std::string&
sid )
149 m_plugins.push_back( plugin );
153 Session::Jingle::Jingle(
const Tag* tag )
177 Session::Jingle::~Jingle()
182 const std::string& Session::Jingle::filterString()
const
184 static const std::string filter =
"/iq/jingle[@xmlns='" +
XMLNS_JINGLE +
"']";
188 Tag* Session::Jingle::tag()
const
193 Tag* t =
new Tag(
"jingle" );
195 t->
addAttribute(
"action", util::lookup( m_action, actionValues ) );
205 PluginList::const_iterator it = m_plugins.begin();
206 for( ; it != m_plugins.end(); ++it )
214 return new Jingle( *
this );
220 : m_parent( parent ), m_state(
Ended ), m_remote( callee ),
221 m_handler( jsh ), m_valid( false )
223 if( !m_parent || !m_handler || !m_remote )
226 m_initiator = m_parent->jid();
227 m_sid = m_parent->getID();
233 : m_parent( parent ), m_state(
Ended ), m_handler( jsh ), m_valid( false )
235 if( !m_parent || !m_handler || !callee )
239 m_sid = jingle->
sid();
316 if( !content || m_state >
Pending )
325 if( plugins.empty() || m_state !=
Pending )
342 if( !content || !m_initiator || m_state >=
Pending )
351 if( plugins.empty() || !m_initiator || m_state >=
Pending )
400 bool Session::doAction(
Action action,
const Plugin* plugin )
403 pl.push_back( plugin );
404 return doAction( action, pl );
409 if( !m_valid || !m_parent )
413 init.addExtension(
new Jingle( action, m_initiator, m_responder, plugins, m_sid ) );
414 m_parent->
send( init,
this, action );
422 if( !j || j->sid() != m_sid || !m_handler || !m_parent )
425 switch( j->action() )
429 m_responder = j->responder();
433 m_initiator = j->initiator();
435 m_responder = m_parent->
jid();
445 m_parent->
send( re );
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
const std::string getID()
void removeIDHandler(IqHandler *ih)
A stanza error abstraction implemented as a StanzaExtension.
An abstraction of an IQ stanza.
bool setJID(const std::string &jid)
const std::string & full() const
An abstraction of a Jingle Content Type. This is part of Jingle (XEP-0166).
An abstraction of a Jingle plugin. This is part of Jingle (XEP-0166 et al.)
A Jingle session handler.
virtual void handleSessionActionError(Action action, Session *session, const Error *error)=0
virtual void handleSessionAction(Action action, Session *session, const Session::Jingle *jingle)=0
This is an abstraction of Jingle's (XEP-0166) <jingle> element as a StanzaExtension.
const std::string & sid() const
virtual Tag * tag() const
An abstraction of a Jingle (XEP-0166) session terminate reason.
Reason(Reasons reason, const std::string &sid=EmptyString, const std::string &text=EmptyString)
virtual Plugin * clone() const
virtual const std::string & filterString() const
virtual Tag * tag() const
bool contentReject(const Content *content)
bool transportReplace(const Content *content)
bool sessionAccept(const Content *content)
bool contentRemove(const Content *content)
bool sessionInfo(const Plugin *info)
bool transportReject(const Content *content)
bool transportInfo(const Plugin *info)
bool contentAdd(const Content *content)
bool sessionInitiate(const Content *content)
bool transportAccept(const Content *content)
virtual void handleIqID(const IQ &iq, int context)
virtual bool handleIq(const IQ &iq)
bool contentModify(const Content *content)
const std::string & sid() const
const JID & responder() const
bool securityInfo(const Plugin *info)
bool descriptionInfo(const Plugin *info)
const JID & initiator() const
bool contentAccept(const Content *content)
bool sessionTerminate(Session::Reason *reason)
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
const std::string & id() const
const StanzaExtension * findExtension(int type) const
This is an abstraction of an XML element.
bool addAttribute(Attribute *attr)
void addChild(Tag *child)
const std::string & findAttribute(const std::string &name) const
const std::string & name() const
const TagList & children() const
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
std::list< const Plugin * > PluginList
void clearList(std::list< T * > &L)
The namespace for the gloox library.
std::list< Tag * > TagList
const std::string XMLNS_JINGLE