Yate
|
A basic Jingle session. More...
#include <yatejingle.h>
Public Types | |
enum | Version { Version0 = 0, Version1 = 1, VersionUnknown } |
enum | Reason { ReasonBusy, ReasonDecline, ReasonConn, ReasonMedia, ReasonTransport, ReasonNoError, ReasonOk, ReasonNoApp, ReasonAltSess, ReasonUnknown, ReasonTransfer, ReasonNone } |
enum | State { Idle = 0, Pending = 1, Active = 2, Ending = 3, Destroy = 4 } |
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 } |
Public Member Functions | |
virtual | ~JGSession () |
Version | version () const |
bool | outgoing () const |
const String & | sid () const |
const JabberID & | local () const |
const JabberID & | remote () const |
State | state () const |
const JBStream * | stream () const |
void * | userData () |
void | userData (void *userdata) |
virtual XMLElement * | checkJingle (XMLElement *xml) |
Action | getAction (XMLElement *xml) |
bool | acceptEvent (JBEvent *event, const String &sid=String::empty()) |
bool | confirm (XMLElement *xml, XMPPError::Type error=XMPPError::NoError, const char *text=0, XMPPError::ErrorType type=XMPPError::TypeModify) |
virtual bool | accept (const ObjList &contents, String *stanzaId=0) |
virtual bool | hangup (int reason, const char *msg=0) |
virtual XMLElement * | createHoldXml () |
virtual XMLElement * | createActiveXml () |
virtual bool | sendContent (Action action, const ObjList &contents, String *stanzaId=0) |
bool | sendContent (Action action, const JGSessionContent *content, String *stanzaId=0) |
virtual bool | sendStreamHosts (const ObjList &hosts, String *stanzaId=0) |
virtual bool | sendStreamHostUsed (const char *jid, const char *stanzaId) |
void | buildSocksDstAddr (String &buf) |
bool | sendInfo (XMLElement *xml, String *stanzaId=0) |
bool | sendDtmf (const char *dtmf, unsigned int msDuration=0, String *stanzaId=0) |
bool | sendMessage (const char *msg) |
bool | hasFeature (XMPPNamespace::Type feature) |
Static Public Member Functions | |
static XMLElement * | buildTransfer (const String &transferTo, const String &transferFrom, const String &sid=String::empty()) |
static Version | lookupVersion (const char *value, Version def=VersionUnknown) |
static const char * | lookupVersion (int value, const char *def="unknown") |
static int | lookupReason (const char *value, int def=ReasonOk) |
static const char * | lookupReason (int value, const char *def=0) |
static const char * | lookupState (int state) |
static const char * | lookupAction (int act, Version ver) |
static Action | lookupAction (const char *str, Version ver) |
Static Public Attributes | |
static TokenDict | s_versions [] |
static TokenDict | s_reasons [] |
static TokenDict | s_states [] |
static TokenDict | s_actions0 [] |
static TokenDict | s_actions1 [] |
Protected Member Functions | |
JGSession (Version ver, JGEngine *engine, JBStream *stream, const String &callerJID, const String &calledJID, const char *msg=0) | |
JGSession (Version ver, JGEngine *engine, JBEvent *event, const String &id) | |
virtual bool | initiate (const ObjList &contents, XMLElement *extra, const char *subject=0)=0 |
virtual JGEvent * | getEvent (u_int64_t time) |
virtual void | destroyed () |
void | enqueue (JBEvent *event) |
bool | sendStanza (XMLElement *stanza, String *stanzaId=0, bool confirmation=true, bool ping=false) |
bool | sendPing (u_int64_t msecNow) |
virtual JGEvent * | decodeJingle (JBEvent *jbev)=0 |
virtual XMLElement * | createJingle (Action action, XMLElement *element1=0, XMLElement *element2=0, XMLElement *element3=0)=0 |
virtual XMLElement * | createDtmf (const char *dtmf, unsigned int msDuration=0)=0 |
virtual void | processJingleSetLastEvent (JBEvent &ev) |
virtual bool | processJabberIqResponse (JBEvent &ev) |
virtual void | processJabberIqEvent (JBEvent &ev) |
void | eventTerminated (JGEvent *event) |
void | changeState (State newState) |
Protected Attributes | |
Version | m_version |
State | m_state |
u_int64_t | m_timeToPing |
JGEngine * | m_engine |
JBStream * | m_stream |
bool | m_outgoing |
String | m_sid |
JabberID | m_localJID |
JabberID | m_remoteJID |
ObjList | m_events |
JGEvent * | m_lastEvent |
bool | m_recvTerminate |
void * | m_private |
String | m_localSid |
u_int32_t | m_stanzaId |
ObjList | m_sentStanza |
Friends | |
class | JGEvent |
class | JGEngine |
A basic Jingle session.
This class is a base class for all specific jingle sessions
enum Action |
Jingle action enumeration
enum Reason |
Jingle defined termination reasons
enum State |
Session state enumeration
enum Version |
Jingle session version
virtual ~JGSession | ( | ) | [virtual] |
Destructor
JGSession | ( | Version | ver, |
JGEngine * | engine, | ||
JBStream * | stream, | ||
const String & | callerJID, | ||
const String & | calledJID, | ||
const char * | msg = 0 |
||
) | [protected] |
Constructor. Create an outgoing session
ver | The session version |
engine | The engine that owns this session |
stream | The stream this session is bound to |
callerJID | The caller's full JID |
calledJID | The called party's full JID |
msg | Optional message to be sent before session initiate |
Constructor. Create an incoming session.
ver | The session version |
engine | The engine that owns this session |
event | A valid Jabber Jingle event with action session initiate |
id | Session id |
Accept a Pending incoming session. This method is thread safe
contents | The list of accepted contents |
stanzaId | Optional string to be filled with sent stanza id (used to track the response) |
Reimplemented in JGSession0, and JGSession1.
Ask this session to accept an event
event | The event to accept |
sid | The session id if this is a request |
void buildSocksDstAddr | ( | String & | buf | ) |
Build SOCKS SHA1 dst.addr used by file transfer
buf | Destination string |
static XMLElement* buildTransfer | ( | const String & | transferTo, |
const String & | transferFrom, | ||
const String & | sid = String::empty() |
||
) | [static] |
Build a transfer element
transferTo | The JID to transfer to |
transferFrom | The transferror's JID |
sid | Optional session id used for attended transfer (empty for unattended transfer) |
void changeState | ( | State | newState | ) | [protected] |
Changed session state
newState | Session new state |
virtual XMLElement* checkJingle | ( | XMLElement * | xml | ) | [inline, virtual] |
Check if a given XML element is valid jingle one
xml | Element to check |
Reimplemented in JGSession0, and JGSession1.
bool confirm | ( | XMLElement * | xml, |
XMPPError::Type | error = XMPPError::NoError , |
||
const char * | text = 0 , |
||
XMPPError::ErrorType | type = XMPPError::TypeModify |
||
) |
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)
xml | The element to confirm |
error | The error condition |
text | Optional text to add to the error element |
type | Error type |
virtual XMLElement* createActiveXml | ( | ) | [inline, virtual] |
Create an 'active' child to be added to a session-info element
Reimplemented in JGSession1.
virtual XMLElement* createDtmf | ( | const char * | dtmf, |
unsigned int | msDuration = 0 |
||
) | [protected, pure virtual] |
Create a dtmf XML element
dtmf | The dtmf string |
msDuration | The tone duration in miliseconds. Ignored if 0 |
Implemented in JGSession0, and JGSession1.
virtual XMLElement* createHoldXml | ( | ) | [inline, virtual] |
Create a 'hold' child to be added to a session-info element
Reimplemented in JGSession1.
virtual XMLElement* createJingle | ( | Action | action, |
XMLElement * | element1 = 0 , |
||
XMLElement * | element2 = 0 , |
||
XMLElement * | element3 = 0 |
||
) | [protected, pure virtual] |
Create an 'iq' of type 'set' with a 'jingle' child
action | The action of the Jingle stanza |
element1 | Optional child element |
element2 | Optional child element |
element3 | Optional child element |
Implemented in JGSession0, and JGSession1.
Decode a valid jingle set event. Set the event's data on success
jbev | The event to decode |
Implemented in JGSession0, and JGSession1.
virtual void destroyed | ( | ) | [protected, virtual] |
Release this session and its memory
Reimplemented from RefObject.
void enqueue | ( | JBEvent * | event | ) | [protected] |
Enqueue a Jabber engine event. This method is thread safe
event | The event event to process |
void eventTerminated | ( | JGEvent * | event | ) | [protected] |
Terminate notification from an event. Reset the last generated event
event | Terminated (processed) event |
Action getAction | ( | XMLElement * | xml | ) | [inline] |
Get an action (jingle element type) from a jingle element
xml | Element to check |
References XMLElement::getAttribute().
virtual JGEvent* getEvent | ( | u_int64_t | time | ) | [protected, virtual] |
Get a Jingle event from the queue. This method is thread safe
time | Current time in miliseconds |
virtual bool hangup | ( | int | reason, |
const char * | msg = 0 |
||
) | [virtual] |
Close a Pending or Active session This method is thread safe
reason | Termination reason |
msg | Optional termination message |
bool hasFeature | ( | XMPPNamespace::Type | feature | ) |
Check if the remote party supports a given feature
feature | The requested feature |
virtual bool initiate | ( | const ObjList & | contents, |
XMLElement * | extra, | ||
const char * | subject = 0 |
||
) | [protected, pure virtual] |
Build and send the initial message on an outgoing session
contents | The session contents to be sent with session initiate element |
extra | Optional extra child to be added to the session initiate element |
subject | Optional session subject |
Implemented in JGSession0, and JGSession1.
const JabberID& local | ( | ) | const [inline] |
Get the local peer's JID
static const char* lookupAction | ( | int | act, |
Version | ver | ||
) | [static] |
Get the name of an action
act | The action to find |
ver | Session version to use |
Referenced by JGEvent::actionName().
Get the action associated with a given string
str | The action name |
ver | Session version to use |
static int lookupReason | ( | const char * | value, |
int | def = ReasonOk |
||
) | [inline, static] |
Get the termination code associated with a text
value | The termination text |
def | Default value to return if not found |
References TelEngine::lookup().
static const char* lookupReason | ( | int | value, |
const char * | def = 0 |
||
) | [inline, static] |
Get the termination code associated with a text
value | The termination code |
def | Default value to return if not found |
References TelEngine::lookup().
static const char* lookupState | ( | int | state | ) | [inline, static] |
Get the name of a session state
state | The state to find |
References TelEngine::lookup().
static const char* lookupVersion | ( | int | value, |
const char * | def = "unknown" |
||
) | [inline, static] |
Get the session version name
value | The version value |
def | Default value to return if not found |
References TelEngine::lookup().
Get the session version associated with a text
value | The version text |
def | Default value to return if not found |
References TelEngine::lookup().
bool outgoing | ( | ) | const [inline] |
Get the session direction
virtual void processJabberIqEvent | ( | JBEvent & | ev | ) | [protected, virtual] |
Method called in getEvent() to process a generic jabber iq event
ev | The event to process |
Reimplemented in JGSession1.
virtual bool processJabberIqResponse | ( | JBEvent & | ev | ) | [protected, virtual] |
Method called in getEvent() to process a jabber event carrying a response
ev | The event to process |
virtual void processJingleSetLastEvent | ( | JBEvent & | ev | ) | [protected, virtual] |
Method called in getEvent() to process a last event set from a jingle set jabber event
ev | The event to process |
const JabberID& remote | ( | ) | const [inline] |
Get the remote peer's JID
virtual bool sendContent | ( | Action | action, |
const ObjList & | contents, | ||
String * | stanzaId = 0 |
||
) | [inline, virtual] |
Send a stanza with session content(s) This method is thread safe
action | Must be a transport- or content- action |
contents | Non empty list with content(s) to send |
stanzaId | Optional string to be filled with sent stanza id (used to track the response) |
Reimplemented in JGSession0, and JGSession1.
bool sendContent | ( | Action | action, |
const JGSessionContent * | content, | ||
String * | stanzaId = 0 |
||
) | [inline] |
Send a stanza with a session content This method is thread safe
action | Must be a transport- or content- action |
content | The content to send |
stanzaId | Optional string to be filled with sent stanza id (used to track the response) |
References ObjList::append(), and ObjList::setDelete().
bool sendDtmf | ( | const char * | dtmf, |
unsigned int | msDuration = 0 , |
||
String * | stanzaId = 0 |
||
) |
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
dtmf | The dtmf string |
msDuration | The tone duration in miliseconds. Ignored if 0 |
stanzaId | Optional string to be filled with sent stanza id (used to track the response) |
bool sendInfo | ( | XMLElement * | xml, |
String * | stanzaId = 0 |
||
) |
Send a session info element to the remote peer. This method is thread safe
xml | The XMLElement carried by the session info element |
stanzaId | Optional string to be filled with sent stanza id (used to track the response) |
bool sendMessage | ( | const char * | msg | ) | [inline] |
Send a message to the remote peer. This method is thread safe
msg | The message to send |
References JBMessage::createMessage().
bool sendPing | ( | u_int64_t | msecNow | ) | [protected] |
Send a ping (empty session info) stanza to the remote peer if it's time to do it
msecNow | The current time |
bool sendStanza | ( | XMLElement * | stanza, |
String * | stanzaId = 0 , |
||
bool | confirmation = true , |
||
bool | ping = false |
||
) | [protected] |
Send a stanza to the remote peer
stanza | The stanza to send |
stanzaId | Optional string to be filled with sent stanza id (used to track the response) |
confirmation | True if the stanza needs confirmation (add 'id' attribute) |
ping | True if the stanza is a ping one |
Send a stanza with stream hosts This method is thread safe
hosts | The list of hosts to send |
stanzaId | Optional string to be filled with sent stanza id (used to track the response) |
Reimplemented in JGSession1.
virtual bool sendStreamHostUsed | ( | const char * | jid, |
const char * | stanzaId | ||
) | [inline, 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
jid | The stream host to send |
stanzaId | The id of the stanza to confirm |
Reimplemented in JGSession1.
const String& sid | ( | ) | const [inline] |
Get the session id
State state | ( | ) | const [inline] |
Get the session state.
const JBStream* stream | ( | ) | const [inline] |
Get the stream this session is bound to
void* userData | ( | ) | [inline] |
Get the arbitrary user data of this session
void userData | ( | void * | userdata | ) | [inline] |
Set the arbitrary user data of this session
userdata | The new arbitrary user data's value |
Version version | ( | ) | const [inline] |
Get the session version
TokenDict s_actions0[] [static] |
Action names for version Version0
TokenDict s_actions1[] [static] |
Action names for version Version1
TokenDict s_versions[] [static] |
Session version names