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();
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 );
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 );
156 if( !tag || tag->
name() !=
"jingle" )
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 )
412 IQ init(
IQ::Set, m_remote, m_parent->getID() );
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 );
An abstraction of a Jingle plugin. This is part of Jingle (XEP-0166 et al.)
bool contentReject(const Content *content)
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
virtual Tag * tag() const
const StanzaExtension * findExtension(int type) const
bool contentRemove(const Content *content)
bool securityInfo(const Plugin *info)
bool descriptionInfo(const Plugin *info)
void clearList(std::list< T * > &L)
An abstraction of an IQ stanza.
void addExtension(const StanzaExtension *se)
const JID & responder() 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
const std::string & name() const
virtual StanzaExtension * clone() const
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 std::string & sid() const
bool transportInfo(const Plugin *info)
bool setJID(const std::string &jid)
The namespace for the gloox library.
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
bool sessionInfo(const Plugin *info)
const std::string & full() const
bool sessionTerminate(Session::Reason *reason)
virtual void handleIqID(const IQ &iq, int context)
virtual const std::string & filterString() const
A Jingle session handler.
bool addAttribute(Attribute *attr)
This is an abstraction of Jingle's (XEP-0166) <jingle> element as a StanzaExtension.
bool transportAccept(const Content *content)
const JID & initiator() const
const std::string & findAttribute(const std::string &name) const
const PluginList & plugins() const
const TagList & children() const
bool contentAccept(const Content *content)
const std::string & sid() const
virtual bool handleIq(const IQ &iq)
const std::string & id() const
virtual const std::string & filterString() const
const std::string XMLNS_JINGLE
virtual Plugin * clone() const
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.
This is an abstraction of an XML element.
An abstraction of a Jingle Content Type. This is part of Jingle (XEP-0166).
virtual Tag * tag() const