class JGSession

A basic Jingle session. More...

Contains pure virtuals
Full nameTelEngine::JGSession
Definition#include <libs/yjingle/yatejingle.h>
InheritsTelEngine::Mutex [public ], TelEngine::RefObject [public ]
Inherited byJGSession0, JGSession1
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods

Public Members

Protected Methods

Protected Members


Detailed Description

This class is a base class for all specific jingle sessions

enum Version { Version0 = 0, Version1 = 1, VersionUnknown }

Version

Jingle session version

enum Reason { ReasonBusy, ReasonDecline, ReasonConn, ReasonMedia, ReasonTransport, ReasonNoError, ReasonOk, ReasonNoApp, ReasonAltSess, ReasonUnknown, ReasonTransfer, ReasonNone }

Reason

Jingle defined termination reasons

enum State { Idle = 0, Pending = 1, Active = 2, Ending = 3, Destroy = 4, }

State

Session state enumeration

enum Action { ActAccept, ActInitiate, ActTerminate, ActInfo, ActTransportInfo, ActTransportAccept, ActTransportReject, ActTransportReplace, ActContentAccept, ActContentAdd, ActContentModify, ActContentReject, ActContentRemove, ActContentInfo, ActTransfer, ActRinging, ActTrying, ActReceived, ActHold, ActActive, ActMute, ActDtmf, ActStreamHost, ActCount, }

Action

Jingle action enumeration

 ~JGSession ()

~JGSession

[virtual]

Destructor

inline Version  version ()

version

[const]

Get the session version

Returns: The session version

inline bool  outgoing ()

outgoing

[const]

Get the session direction

Returns: True if it is an outgoing session

inline const String&  sid ()

sid

[const]

Get the session id

Returns: The session id

inline const JabberID&  local ()

local

[const]

Get the local peer's JID

Returns: The local peer's JID

inline const JabberID&  remote ()

remote

[const]

Get the remote peer's JID

Returns: The remote peer's JID

inline State  state ()

state

[const]

Get the session state.

Returns: The session state as enumeration.

inline const JBStream*  stream ()

stream

[const]

Get the stream this session is bound to

Returns: The stream this session is bound to

inline void*  userData ()

userData

Get the arbitrary user data of this session

Returns: The arbitrary user data of this session

inline void  userData (void* userdata)

userData

Set the arbitrary user data of this session

Parameters:
userdataThe new arbitrary user data's value

XMLElement*  checkJingle (XMLElement* xml)

checkJingle

[virtual]

Check if a given XML element is valid jingle one

Parameters:
xmlElement to check

Returns: The given element if it's a valid jingle element, 0 otherwise

inline Action  getAction (XMLElement* xml)

getAction

Get an action (jingle element type) from a jingle element

Parameters:
xmlElement to check

Returns: The found action, ActCount if not found or unknown

bool  acceptEvent (JBEvent* event, const String& sid = String::empty())

acceptEvent

Ask this session to accept an event

Parameters:
eventThe event to accept
sidThe session id if this is a request

Returns: True if accepted (the event was enqueued), false if not

bool  confirm (XMLElement* xml, XMPPError::Type error = XMPPError::NoError, const char* text = 0, XMPPError::ErrorType type = XMPPError::TypeModify)

confirm

Confirm a received element. If the error is NoError a result stanza will be sent. Otherwise, an error stanza will be created and sent and the received element is consumed (attached to the sent error stanza)

Parameters:
xmlThe element to confirm
errorThe error condition
textOptional text to add to the error element
typeError type

Returns: False if send failed or element is 0

bool  accept (const ObjList& contents, String* stanzaId = 0)

accept

[virtual]

Accept a Pending incoming session. This method is thread safe

Parameters:
contentsThe list of accepted contents
stanzaIdOptional string to be filled with sent stanza id (used to track the response)

Returns: False if send failed

bool  hangup (int reason, const char* msg = 0)

hangup

[virtual]

Close a Pending or Active session This method is thread safe

Parameters:
reasonTermination reason
msgOptional termination message

Returns: False if send failed

XMLElement*  createHoldXml ()

createHoldXml

[virtual]

Create a 'hold' child to be added to a session-info element

Returns: Valid XMLElement pointer or 0

XMLElement*  createActiveXml ()

createActiveXml

[virtual]

Create an 'active' child to be added to a session-info element

Returns: Valid XMLElement pointer or 0

bool  sendContent (Action action, const ObjList& contents, String* stanzaId = 0)

sendContent

[virtual]

Send a stanza with session content(s) This method is thread safe

Parameters:
actionMust be a transport- or content- action
contentsNon empty list with content(s) to send
stanzaIdOptional string to be filled with sent stanza id (used to track the response)

Returns: False if send failed

inline bool  sendContent (Action action, const JGSessionContent* content, String* stanzaId = 0)

sendContent

Send a stanza with a session content This method is thread safe

Parameters:
actionMust be a transport- or content- action
contentThe content to send
stanzaIdOptional string to be filled with sent stanza id (used to track the response)

Returns: False if send failed

bool  sendStreamHosts (const ObjList& hosts, String* stanzaId = 0)

sendStreamHosts

[virtual]

Send a stanza with stream hosts This method is thread safe

Parameters:
hostsThe list of hosts to send
stanzaIdOptional string to be filled with sent stanza id (used to track the response)

Returns: False if send failed

bool  sendStreamHostUsed (const char* jid, const char* stanzaId)

sendStreamHostUsed

[virtual]

Send a stanza with a stream host used. If the jid is empty, send an item-not-found error response This method is thread safe

Parameters:
jidThe stream host to send
stanzaIdThe id of the stanza to confirm

Returns: False if send failed

void  buildSocksDstAddr (String& buf)

buildSocksDstAddr

Build SOCKS SHA1 dst.addr used by file transfer

Parameters:
bufDestination string

bool  sendInfo (XMLElement* xml, String* stanzaId = 0)

sendInfo

Send a session info element to the remote peer. This method is thread safe

Parameters:
xmlThe XMLElement carried by the session info element
stanzaIdOptional string to be filled with sent stanza id (used to track the response)

Returns: False on failure

bool  sendDtmf (const char* dtmf, unsigned int msDuration = 0, String* stanzaId = 0)

sendDtmf

Send a dtmf string to remote peer. If the string's length is greater then 1, each character is added as a 'dtmf' child of the jingle element

Parameters:
dtmfThe dtmf string
msDurationThe tone duration in miliseconds. Ignored if 0
stanzaIdOptional string to be filled with sent stanza id (used to track the response)

Returns: False if send failed

inline bool  sendMessage (const char* msg)

sendMessage

Send a message to the remote peer. This method is thread safe

Parameters:
msgThe message to send

Returns: False on socket error

bool  hasFeature (XMPPNamespace::Type feature)

hasFeature

Check if the remote party supports a given feature

Parameters:
featureThe requested feature

Returns: True if the remote party supports the given feature

XMLElement*  buildTransfer (const String& transferTo, const String& transferFrom, const String& sid = String::empty())

buildTransfer

[static]

Build a transfer element

Parameters:
transferToThe JID to transfer to
transferFromThe transferror's JID
sidOptional session id used for attended transfer (empty for unattended transfer)

Returns: Valid XMLElement pointer

inline Version  lookupVersion (const char* value, Version def = VersionUnknown)

lookupVersion

[static]

Get the session version associated with a text

Parameters:
valueThe version text
defDefault value to return if not found

Returns: Session Version value

inline const char*  lookupVersion (int value, const char* def = "unknown")

lookupVersion

[static]

Get the session version name

Parameters:
valueThe version value
defDefault value to return if not found

Returns: Session version name or the default value if not found

inline int  lookupReason (const char* value, int def = ReasonOk)

lookupReason

[static]

Get the termination code associated with a text

Parameters:
valueThe termination text
defDefault value to return if not found

Returns: Termination code

inline const char*  lookupReason (int value, const char* def = 0)

lookupReason

[static]

Get the termination code associated with a text

Parameters:
valueThe termination code
defDefault value to return if not found

Returns: Termination text

const char*  lookupState (int state)

lookupState

[static]

Get the name of a session state

Parameters:
stateThe state to find

Returns: The name of a session state

const char*  lookupAction (int act, Version ver)

lookupAction

[static]

Get the name of an action

Parameters:
actThe action to find
verSession version to use

Returns: The name of an action

Action  lookupAction (const char* str, Version ver)

lookupAction

[static]

Get the action associated with a given string

Parameters:
strThe action name
verSession version to use

Returns: The name of an action

static TokenDict s_versions[]

s_versions[]

static TokenDict s_reasons[]

s_reasons[]

static TokenDict s_states[]

s_states[]

static TokenDict s_actions0[]

s_actions0[]

static TokenDict s_actions1[]

s_actions1[]

 JGSession (Version ver, JGEngine* engine, JBStream* stream, const String& callerJID, const String& calledJID, const char* msg = 0)

JGSession

[protected]

Constructor. Create an outgoing session

Parameters:
verThe session version
engineThe engine that owns this session
streamThe stream this session is bound to
callerJIDThe caller's full JID
calledJIDThe called party's full JID
msgOptional message to be sent before session initiate

 JGSession (Version ver, JGEngine* engine, JBEvent* event, const String& id)

JGSession

[protected]

Constructor. Create an incoming session.

Parameters:
verThe session version
engineThe engine that owns this session
eventA valid Jabber Jingle event with action session initiate
idSession id

bool  initiate (const ObjList& contents, XMLElement* extra, const char* subject = 0)

initiate

[protected pure virtual]

Build and send the initial message on an outgoing session

Parameters:
contentsThe session contents to be sent with session initiate element
extraOptional extra child to be added to the session initiate element
subjectOptional session subject

Returns: True on success

JGEvent*  getEvent (u_int64_t time)

getEvent

[protected virtual]

Get a Jingle event from the queue. This method is thread safe

Parameters:
timeCurrent time in miliseconds

Returns: JGEvent pointer or 0

void  destroyed ()

destroyed

[protected virtual]

Release this session and its memory

Reimplemented from RefObject.

void  enqueue (JBEvent* event)

enqueue

[protected]

Enqueue a Jabber engine event. This method is thread safe

Parameters:
eventThe event event to process

bool  sendStanza (XMLElement* stanza, String* stanzaId = 0, bool confirmation = true, bool ping = false)

sendStanza

[protected]

Send a stanza to the remote peer

Parameters:
stanzaThe stanza to send
stanzaIdOptional string to be filled with sent stanza id (used to track the response)
confirmationTrue if the stanza needs confirmation (add 'id' attribute)
pingTrue if the stanza is a ping one

Returns: True on success

bool  sendPing (u_int64_t msecNow)

sendPing

[protected]

Send a ping (empty session info) stanza to the remote peer if it's time to do it

Parameters:
msecNowThe current time

Returns: True if a ping was succesfully sent

JGEvent*  decodeJingle (JBEvent* jbev)

decodeJingle

[protected pure virtual]

Decode a valid jingle set event. Set the event's data on success

Parameters:
jbevThe event to decode

Returns: JGEvent pointer or 0

XMLElement*  createJingle (Action action, XMLElement* element1 = 0, XMLElement* element2 = 0, XMLElement* element3 = 0)

createJingle

[protected pure virtual]

Create an 'iq' of type 'set' with a 'jingle' child

Parameters:
actionThe action of the Jingle stanza
element1Optional child element
element2Optional child element
element3Optional child element

Returns: Valid XMLElement pointer

XMLElement*  createDtmf (const char* dtmf, unsigned int msDuration = 0)

createDtmf

[protected pure virtual]

Create a dtmf XML element

Parameters:
dtmfThe dtmf string
msDurationThe tone duration in miliseconds. Ignored if 0

Returns: Valid XMLElement pointer or 0

void  processJingleSetLastEvent (JBEvent& ev)

processJingleSetLastEvent

[protected virtual]

Method called in getEvent() to process a last event set from a jingle set jabber event

Parameters:
evThe event to process

bool  processJabberIqResponse (JBEvent& ev)

processJabberIqResponse

[protected virtual]

Method called in getEvent() to process a jabber event carrying a response

Parameters:
evThe event to process

Returns: False to stop further processing

void  processJabberIqEvent (JBEvent& ev)

processJabberIqEvent

[protected virtual]

Method called in getEvent() to process a generic jabber iq event

Parameters:
evThe event to process

void  eventTerminated (JGEvent* event)

eventTerminated

[protected]

Terminate notification from an event. Reset the last generated event

Parameters:
eventTerminated (processed) event

void  changeState (State newState)

changeState

[protected]

Changed session state

Parameters:
newStateSession new state

Version m_version

m_version

[protected]

State m_state

m_state

[protected]

u_int64_t m_timeToPing

m_timeToPing

[protected]

JGEngine* m_engine

m_engine

[protected]

JBStream* m_stream

m_stream

[protected]

bool m_outgoing

m_outgoing

[protected]

String m_sid

m_sid

[protected]

JabberID m_localJID

m_localJID

[protected]

JabberID m_remoteJID

m_remoteJID

[protected]

ObjList m_events

m_events

[protected]

JGEvent* m_lastEvent

m_lastEvent

[protected]

bool m_recvTerminate

m_recvTerminate

[protected]

void* m_private

m_private

[protected]

String m_localSid

m_localSid

[protected]

u_int32_t m_stanzaId

m_stanzaId

[protected]

ObjList m_sentStanza

m_sentStanza

[protected]


Generated by: paulc on bussard on Wed Oct 21 01:57:30 2009, using kdoc 2.0a54.