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)
88 if( !
tag ||
tag->name() !=
"reason" )
92 TagList::const_iterator it = l.begin();
93 for( ; it != l.end(); ++it )
95 if( (*it)->name() ==
"text" )
96 m_text = (*it)->cdata();
97 else if( (*it)->xmlns() == XMLNS_JINGLE )
98 m_reason = reasonType( (*it)->name() );
108 static const std::string filter =
"jingle/reason";
117 Tag* t =
new Tag(
"reason" );
118 Tag* r =
new Tag( t, util::lookup( m_reason, reasonValues ) );
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 );
156 if( !
tag ||
tag->name() !=
"jingle" )
159 m_action = actionType(
tag->findAttribute(
"action" ) );
160 m_initiator.setJID(
tag->findAttribute(
"initiator" ) );
161 m_responder.setJID(
tag->findAttribute(
"responder" ) );
162 m_sid =
tag->findAttribute(
"sid" );
164 m_tag =
tag->clone();
184 static const std::string filter =
"/iq/jingle[@xmlns='" +
XMLNS_JINGLE +
"']";
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();
247 m_parent->removeIDHandler(
this );
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 );
447 m_handler->handleSessionAction( j->action(),
this, j );
458 m_handler->handleSessionActionError(
static_cast<Action>( context ),
this, e );
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
const std::string getID()
A stanza error abstraction implemented as a StanzaExtension.
An abstraction of an IQ stanza.
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.).
Plugin(JinglePluginType type)
A Jingle session handler.
This is an abstraction of Jingle's (XEP-0166) <jingle> element as a StanzaExtension.
virtual StanzaExtension * clone() const
virtual const std::string & filterString() const
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
const std::string & sid() const
const std::string & text() 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 JID & responder() const
const std::string & sid() 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...
StanzaExtension(int type)
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)
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
The namespace containing Jingle-related (XEP-0166 et. al.) classes.
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