Yate
|
A Jabber engine. More...
#include <yatejabber.h>
Public Types | |
enum | Protocol { Component = 1, Client = 2 } |
enum | Service { ServiceJingle = 0, ServiceIq = 1, ServiceMessage = 2, ServicePresence = 3, ServiceCommand = 4, ServiceDisco = 5, ServiceStream = 6, ServiceWriteFail = 7, ServiceRoster = 8, ServiceCount = 9 } |
Public Member Functions | |
JBEngine (Protocol proto) | |
virtual | ~JBEngine () |
Protocol | protocol () const |
const JabberID & | componentServer () const |
void | setAlternateDomain (const char *domain=0) |
const JabberID & | getAlternateDomain () const |
const String & | defaultResource () const |
const ObjList & | streams () const |
virtual void | destruct () |
virtual void | initialize (const NamedList ¶ms) |
void | cleanup () |
void | setComponentServer (const char *domain) |
JBStream * | findStream (const String &name) |
JBStream * | getStream (const JabberID *jid=0, bool create=true) |
bool | getStream (JBStream *&stream, bool &release) |
JBClientStream * | createClientStream (NamedList ¶ms) |
bool | receive () |
bool | process (u_int64_t time) |
bool | checkDupId (const JBStream *stream) |
bool | checkComponentFrom (JBComponentStream *stream, const char *from) |
virtual void | connect (JBStream *stream) |
virtual bool | exiting () const |
virtual bool | encryptStream (JBStream *stream) |
void | appendServer (XMPPServerInfo *server, bool open) |
bool | getServerIdentity (String &destination, bool full, const char *token=0, bool domain=true) |
XMPPServerInfo * | findServerInfo (const char *token, bool domain) |
void | attachService (JBService *service, Service type, int prio=-1) |
void | detachService (JBService *service) |
void | printXml (const XMLElement &xml, const JBStream *stream, bool send) const |
Static Public Member Functions | |
static const char * | lookupProto (int proto, const char *def=0) |
static int | lookupProto (const char *proto, int def=0) |
Friends | |
class | JBStream |
A Jabber engine.
This class holds a Jabber engine
enum Protocol |
Jabber protocol type
enum Service |
Service type enumeration
Constructor
proto | The protocol used by the streams belonging to this engine |
virtual ~JBEngine | ( | ) | [virtual] |
Destructor
void appendServer | ( | XMPPServerInfo * | server, |
bool | open | ||
) |
Append a server info element to the list
server | The object to add |
open | True to open the stream, if in component mode |
Attach a service to this engine. This method is thread safe
service | The service to attach |
type | Service type |
prio | Service priority. Set to -1 to use the givent service's priority. A lower values indicates a service with higher priority |
bool checkComponentFrom | ( | JBComponentStream * | stream, |
const char * | from | ||
) |
Check the 'from' attribute received by a Component stream at startup
stream | The calling stream |
from | The from attribute to check |
bool checkDupId | ( | const JBStream * | stream | ) |
Check if an outgoing stream exists with the same id and remote peer
stream | The calling stream |
void cleanup | ( | ) |
Terminate all streams
const JabberID& componentServer | ( | ) | const [inline] |
Get the default component server
virtual void connect | ( | JBStream * | stream | ) | [virtual] |
Asynchronously call the connect method of the given stream if the stream is idle
stream | The stream to connect |
JBClientStream* createClientStream | ( | NamedList & | params | ) |
Create a new client stream. This method is thread safe
params | Stream parameters |
const String& defaultResource | ( | ) | const [inline] |
Get the default resource name.
virtual void destruct | ( | ) | [virtual] |
Cleanup streams. Stop all threads owned by this engine. Release memory
Reimplemented from GenObject.
void detachService | ( | JBService * | service | ) |
Remove a service from all event handlers of this engine. This method is thread safe
service | The service to detach |
virtual bool encryptStream | ( | JBStream * | stream | ) | [virtual] |
Setup the transport layer security for a stream
stream | The stream requesting the operation |
virtual bool exiting | ( | ) | const [inline, virtual] |
Check if this engine is exiting
XMPPServerInfo* findServerInfo | ( | const char * | token, |
bool | domain | ||
) |
Find server info object
token | The search string. If 0 and the Component protocol is used, the default component server will be used |
domain | True to find by domain name. False to find by address |
Find a stream by its name. This method is thread safe
name | The name of the stream to find |
const JabberID& getAlternateDomain | ( | ) | const [inline] |
Get the alternate domain name
bool getServerIdentity | ( | String & | destination, |
bool | full, | ||
const char * | token = 0 , |
||
bool | domain = true |
||
) |
Get the identity of the given server
destination | The destination buffer |
full | True to get the full identity |
token | The search string. If 0 and the component protocol is used, the default server will be used |
domain | True to find by domain name. False to find by address |
Get a stream. Create it not found and requested. For the component protocol, the jid parameter may contain the domain to find, otherwise, the default component will be used. This method won't create a client stream. Use createClientStream(). This method is thread safe
jid | Optional jid to use to find or create the stream |
create | True to create a stream if don't exist. Ignored if the engine's protocol is Client |
bool getStream | ( | JBStream *& | stream, |
bool & | release | ||
) |
Try to get a stream if stream parameter is 0
stream | Stream to check |
release | Set to true on exit if the caller must deref the stream |
virtual void initialize | ( | const NamedList & | params | ) | [virtual] |
Initialize the engine's parameters. Start private streams if requested
params | Engine's parameters |
static int lookupProto | ( | const char * | proto, |
int | def = 0 |
||
) | [inline, static] |
Get the value associated with a protocol name
References TelEngine::lookup().
static const char* lookupProto | ( | int | proto, |
const char * | def = 0 |
||
) | [inline, static] |
Get the name of a protocol
References TelEngine::lookup().
void printXml | ( | const XMLElement & | xml, |
const JBStream * | stream, | ||
bool | send | ||
) | const |
Print an XML element to output
xml | Element to print |
stream | Stream requesting the operation |
send | True if sending, false if receiving |
bool process | ( | u_int64_t | time | ) |
Get events from the streams owned by this engine and send them to a service. Delete them if not processed by a service
time | Current time |
Protocol protocol | ( | ) | const [inline] |
Get the Jabber protocol this engine is using
bool receive | ( | ) |
Keep calling receive() for each stream until no data is received or the thread is terminated
void setAlternateDomain | ( | const char * | domain = 0 | ) | [inline] |
Set the alternate domain name
domain | Name of an acceptable alternate domain |
void setComponentServer | ( | const char * | domain | ) |
Set the default component server to use. The domain must be in the server list. Choose the first one from the server list if the given one doesn't exists. Do nothing if the protocol is not Component
domain | Domain name of the server |
const ObjList& streams | ( | ) | const [inline] |
Get the stream list