jinglesession.h
/*
Copyright (c) 2007-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef JINGLESESSION_H__
#define JINGLESESSION_H__
#include "stanzaextension.h"
#include "tag.h"
#include "iqhandler.h"
#include "jingleplugin.h"
#include <string>
namespace gloox
{
class ClientBase;
namespace Jingle
{
class Description;
class Transport;
class SessionHandler;
class Content;
enum Action
{
ContentAccept,
ContentAdd,
ContentModify,
ContentReject,
ContentRemove,
DescriptionInfo,
SecurityInfo,
SessionAccept,
SessionInfo,
SessionInitiate,
SessionTerminate,
TransportAccept,
TransportInfo,
TransportReject,
TransportReplace,
InvalidAction
};
class GLOOX_API Session : public IqHandler
{
friend class SessionManager;
public:
enum State
{
Ended,
Pending,
Active
};
class GLOOX_API Reason : public Plugin
{
public:
enum Reasons
{
AlternativeSession,
Busy,
Cancel,
ConnectivityError,
Decline,
Expired,
FailedApplication,
FailedTransport,
GeneralError,
Gone,
IncompatibleParameters,
MediaError,
SecurityError,
Success,
Timeout,
UnsupportedApplications,
UnsupportedTransports,
InvalidReason
};
Reason( Reasons reason, const std::string& sid = EmptyString,
const std::string& text = EmptyString );
Reason( const Tag* tag = 0 );
virtual ~Reason();
Reasons reason() const { return m_reason; }
const std::string& sid() const { return m_sid; }
const std::string& text() const { return m_text; }
// reimplemented from Plugin
virtual const std::string& filterString() const;
// reimplemented from Plugin
virtual Tag* tag() const;
// reimplemented from Plugin
virtual Plugin* newInstance( const Tag* tag ) const { return new Reason( tag ); }
// reimplemented from Plugin
virtual Plugin* clone() const;
private:
Reasons m_reason;
std::string m_sid;
std::string m_text;
};
class Jingle : public StanzaExtension
{
friend class Session;
public:
Jingle( const Tag* tag = 0 );
virtual ~Jingle();
const std::string& sid() const { return m_sid; }
const JID& initiator() const { return m_initiator; }
const JID& responder() const { return m_responder; }
Action action() const { return m_action; }
void addPlugin( const Plugin* plugin ) { if( plugin ) m_plugins.push_back( plugin ); }
const PluginList& plugins() const { return m_plugins; }
Tag* embeddedTag() const { return m_tag; }
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new Jingle( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const;
#ifdef JINGLE_TEST
public:
#else
private:
#endif
Jingle( Action action, const JID& initiator, const JID& responder,
const PluginList& plugins, const std::string& sid );
#ifdef JINGLE_TEST
Jingle( Action action, const JID& initiator, const JID& responder,
const Plugin* plugin, const std::string& sid );
#endif
// /**
// * Copy constructor.
// * @param right The instance to copy.
// */
// Jingle( const Jingle& right );
Action m_action;
std::string m_sid;
JID m_initiator;
JID m_responder;
PluginList m_plugins;
Tag* m_tag;
};
virtual ~Session();
void setInitiator( const JID& initiator ) { m_initiator = initiator; }
const JID& initiator() const { return m_initiator; }
const JID& responder() const { return m_responder; }
void setResponder( const JID& jid ) { m_responder = jid; }
void setHandler( SessionHandler* handler ) { m_handler = handler; }
bool contentAccept( const Content* content );
bool contentAdd( const Content* content );
bool contentAdd( const PluginList& contents );
bool contentModify( const Content* content );
bool contentReject( const Content* content );
bool contentRemove( const Content* content );
bool descriptionInfo( const Plugin* info );
bool securityInfo( const Plugin* info );
bool sessionAccept( const Content* content );
bool sessionAccept( const PluginList& plugins );
bool sessionInfo( const Plugin* info );
bool sessionInitiate( const Content* content );
bool sessionInitiate( const PluginList& plugins );
bool sessionTerminate( Session::Reason* reason );
bool transportAccept( const Content* content );
bool transportInfo( const Plugin* info );
bool transportReject( const Content* content );
bool transportReplace( const Content* content );
State state() const { return m_state; }
void setSID( const std::string& sid ) { m_sid = sid; }
const std::string& sid() const { return m_sid; }
// reimplemented from IqHandler
virtual bool handleIq( const IQ& iq );
// reimplemented from IqHandler
virtual void handleIqID( const IQ& iq, int context );
#ifdef JINGLE_TEST
public:
#else
private:
#endif
Session( ClientBase* parent, const JID& callee, SessionHandler* jsh );
Session( ClientBase* parent, const JID& callee, const Session::Jingle* jingle,
SessionHandler* jsh );
bool doAction( Action action, const Plugin* plugin );
bool doAction( Action action, const PluginList& plugin );
ClientBase* m_parent;
State m_state;
JID m_remote;
JID m_initiator;
JID m_responder;
SessionHandler* m_handler;
std::string m_sid;
bool m_valid;
};
}
}
#endif // JINGLESESSION_H__
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::IQ
An abstraction of an IQ stanza.
Definition iq.h:34
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::Jingle::Content
An abstraction of a Jingle Content Type. This is part of Jingle (XEP-0166).
Definition jinglecontent.h:42
gloox::Jingle::Plugin
An abstraction of a Jingle plugin. This is part of Jingle (XEP-0166 et al.).
Definition jingleplugin.h:68
gloox::Jingle::Plugin::Plugin
Plugin(JinglePluginType type)
Definition jingleplugin.h:76
gloox::Jingle::SessionHandler
A Jingle session handler.
Definition jinglesessionhandler.h:33
gloox::Jingle::Session::Jingle
This is an abstraction of Jingle's (XEP-0166) <jingle> element as a StanzaExtension.
Definition jinglesession.h:199
gloox::Jingle::Session::Jingle::embeddedTag
Tag * embeddedTag() const
Definition jinglesession.h:255
gloox::Jingle::Session::Jingle::responder
const JID & responder() const
Definition jinglesession.h:231
gloox::Jingle::Session::Jingle::addPlugin
void addPlugin(const Plugin *plugin)
Definition jinglesession.h:243
gloox::Jingle::Session::Jingle::plugins
const PluginList & plugins() const
Definition jinglesession.h:249
gloox::Jingle::Session::Jingle::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition jinglesession.h:261
gloox::Jingle::Session::Jingle::sid
const std::string & sid() const
Definition jinglesession.h:219
gloox::Jingle::Session::Jingle::Jingle
Jingle(const Tag *tag=0)
Definition jinglesession.cpp:153
gloox::Jingle::Session::Jingle::initiator
const JID & initiator() const
Definition jinglesession.h:225
gloox::Jingle::Session::Jingle::tag
virtual Tag * tag() const
Definition jinglesession.cpp:188
gloox::Jingle::Session::Jingle::action
Action action() const
Definition jinglesession.h:237
gloox::Jingle::Session::Reason
An abstraction of a Jingle (XEP-0166) session terminate reason.
Definition jinglesession.h:105
gloox::Jingle::Session::Reason::Reason
Reason(Reasons reason, const std::string &sid=EmptyString, const std::string &text=EmptyString)
Definition jinglesession.cpp:78
gloox::Jingle::Session::Reason::Reasons
Reasons
Definition jinglesession.h:111
gloox::Jingle::Session::Reason::UnsupportedTransports
@ UnsupportedTransports
Definition jinglesession.h:128
gloox::Jingle::Session::Reason::MediaError
@ MediaError
Definition jinglesession.h:123
gloox::Jingle::Session::Reason::Busy
@ Busy
Definition jinglesession.h:113
gloox::Jingle::Session::Reason::ConnectivityError
@ ConnectivityError
Definition jinglesession.h:115
gloox::Jingle::Session::Reason::UnsupportedApplications
@ UnsupportedApplications
Definition jinglesession.h:127
gloox::Jingle::Session::Reason::AlternativeSession
@ AlternativeSession
Definition jinglesession.h:112
gloox::Jingle::Session::Reason::FailedTransport
@ FailedTransport
Definition jinglesession.h:119
gloox::Jingle::Session::Reason::InvalidReason
@ InvalidReason
Definition jinglesession.h:129
gloox::Jingle::Session::Reason::GeneralError
@ GeneralError
Definition jinglesession.h:120
gloox::Jingle::Session::Reason::SecurityError
@ SecurityError
Definition jinglesession.h:124
gloox::Jingle::Session::Reason::Cancel
@ Cancel
Definition jinglesession.h:114
gloox::Jingle::Session::Reason::Timeout
@ Timeout
Definition jinglesession.h:126
gloox::Jingle::Session::Reason::IncompatibleParameters
@ IncompatibleParameters
Definition jinglesession.h:122
gloox::Jingle::Session::Reason::FailedApplication
@ FailedApplication
Definition jinglesession.h:118
gloox::Jingle::Session::Reason::Decline
@ Decline
Definition jinglesession.h:116
gloox::Jingle::Session::Reason::Gone
@ Gone
Definition jinglesession.h:121
gloox::Jingle::Session::Reason::Expired
@ Expired
Definition jinglesession.h:117
gloox::Jingle::Session::Reason::Success
@ Success
Definition jinglesession.h:125
gloox::Jingle::Session::Reason::newInstance
virtual Plugin * newInstance(const Tag *tag) const
Definition jinglesession.h:179
gloox::Jingle::Session::Reason::reason
Reasons reason() const
Definition jinglesession.h:156
gloox::Jingle::Session::Reason::sid
const std::string & sid() const
Definition jinglesession.h:163
gloox::Jingle::Session::Reason::text
const std::string & text() const
Definition jinglesession.h:170
gloox::Jingle::Session::Reason::tag
virtual Tag * tag() const
Definition jinglesession.cpp:112
gloox::Jingle::Session
This is an implementation of a Jingle Session (XEP-0166).
Definition jinglesession.h:81
gloox::Jingle::Session::setInitiator
void setInitiator(const JID &initiator)
Definition jinglesession.h:330
gloox::Jingle::Session::setResponder
void setResponder(const JID &jid)
Definition jinglesession.h:352
gloox::Jingle::Session::State
State
Definition jinglesession.h:90
gloox::Jingle::Session::Pending
@ Pending
Definition jinglesession.h:92
gloox::Jingle::Session::Active
@ Active
Definition jinglesession.h:93
gloox::Jingle::Session::Ended
@ Ended
Definition jinglesession.h:91
gloox::Jingle::Session::responder
const JID & responder() const
Definition jinglesession.h:343
gloox::Jingle::Session::setHandler
void setHandler(SessionHandler *handler)
Definition jinglesession.h:358
gloox::Jingle::Session::sid
const std::string & sid() const
Definition jinglesession.h:525
gloox::Jingle::Session::state
State state() const
Definition jinglesession.h:512
gloox::Jingle::Session::initiator
const JID & initiator() const
Definition jinglesession.h:336
gloox::Jingle::Session::setSID
void setSID(const std::string &sid)
Definition jinglesession.h:519
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition stanzaextension.h:204
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::Jingle
The namespace containing Jingle-related (XEP-0166 et. al.) classes.
Definition jinglecontent.cpp:22
gloox::Jingle::Action
Action
Definition jinglesession.h:50
gloox::Jingle::ContentAdd
@ ContentAdd
Definition jinglesession.h:52
gloox::Jingle::ContentModify
@ ContentModify
Definition jinglesession.h:53
gloox::Jingle::ContentRemove
@ ContentRemove
Definition jinglesession.h:55
gloox::Jingle::DescriptionInfo
@ DescriptionInfo
Definition jinglesession.h:56
gloox::Jingle::InvalidAction
@ InvalidAction
Definition jinglesession.h:66
gloox::Jingle::TransportReject
@ TransportReject
Definition jinglesession.h:64
gloox::Jingle::ContentAccept
@ ContentAccept
Definition jinglesession.h:51
gloox::Jingle::SessionInfo
@ SessionInfo
Definition jinglesession.h:59
gloox::Jingle::SessionAccept
@ SessionAccept
Definition jinglesession.h:58
gloox::Jingle::SessionInitiate
@ SessionInitiate
Definition jinglesession.h:60
gloox::Jingle::ContentReject
@ ContentReject
Definition jinglesession.h:54
gloox::Jingle::TransportReplace
@ TransportReplace
Definition jinglesession.h:65
gloox::Jingle::SecurityInfo
@ SecurityInfo
Definition jinglesession.h:57
gloox::Jingle::TransportInfo
@ TransportInfo
Definition jinglesession.h:63
gloox::Jingle::TransportAccept
@ TransportAccept
Definition jinglesession.h:62
gloox::Jingle::SessionTerminate
@ SessionTerminate
Definition jinglesession.h:61
gloox::Jingle::PluginList
std::list< const Plugin * > PluginList
Definition jingleplugin.h:52
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124