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 (
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();
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 );
138 m_initiator( initiator ), m_responder( responder ), m_plugins( plugins ), m_tag( 0 )
144 const Plugin* plugin,
const std::string&
sid )
146 m_initiator( initiator ), m_responder( responder ), m_tag( 0 )
149 m_plugins.push_back( plugin );
153 Session::Jingle::Jingle(
const Tag* tag )
156 if( !tag || tag->
name() !=
"jingle" )
164 m_tag = tag->
clone();
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 );
An abstraction of a Jingle plugin. This is part of Jingle (XEP-0166 et al.)
const TagList & children() const
const std::string & sid() const
bool contentReject(const Content *content)
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
void removeIDHandler(IqHandler *ih)
virtual void handleSessionActionError(Action action, Session *session, const Error *error)=0
bool contentRemove(const Content *content)
bool securityInfo(const Plugin *info)
virtual Tag * tag() const
bool descriptionInfo(const Plugin *info)
void clearList(std::list< T * > &L)
An abstraction of an IQ stanza.
virtual void handleSessionAction(Action action, Session *session, const Session::Jingle *jingle)=0
void addExtension(const StanzaExtension *se)
const std::string & sid() const
bool contentModify(const Content *content)
An abstraction of a Jingle (XEP-0166) session terminate reason.
bool transportReplace(const Content *content)
bool contentAdd(const Content *content)
bool transportReject(const Content *content)
std::list< Tag * > TagList
A stanza error abstraction implemented as a StanzaExtension.
bool sessionInitiate(const Content *content)
Reason(Reasons reason, const std::string &sid=EmptyString, const std::string &text=EmptyString)
void addChild(Tag *child)
const JID & initiator() const
bool transportInfo(const Plugin *info)
bool setJID(const std::string &jid)
The namespace for the gloox library.
virtual Plugin * clone() const
This class abstracts a stanza extension, which is usually an element in a specific namespace...
bool sessionInfo(const Plugin *info)
const std::string & findAttribute(const std::string &name) const
bool sessionTerminate(Session::Reason *reason)
virtual void handleIqID(const IQ &iq, int context)
A Jingle session handler.
bool addAttribute(Attribute *attr)
virtual const std::string & filterString() const
This is an abstraction of Jingle's (XEP-0166) element as a StanzaExtension.
const std::string & name() const
bool transportAccept(const Content *content)
const std::string getID()
bool contentAccept(const Content *content)
const std::string & full() const
virtual bool handleIq(const IQ &iq)
const JID & responder() const
const std::string & id() const
const std::string XMLNS_JINGLE
std::list< const Plugin * > PluginList
bool sessionAccept(const Content *content)
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
const StanzaExtension * findExtension(int type) const
This is an abstraction of an XML element.
An abstraction of a Jingle Content Type. This is part of Jingle (XEP-0166).