|
|
This class holds a Jabber engine
enum Protocol { Component = 1, Client = 2, } | Protocol |
Jabber protocol type
enum Service { ServiceJingle = 0, ServiceIq = 1, ServiceMessage = 2, ServicePresence = 3, ServiceCommand = 4, ServiceDisco = 5, ServiceStream = 6, ServiceWriteFail = 7, ServiceRoster = 8, ServiceCount = 9 } | Service |
Service type enumeration
JBEngine (Protocol proto)
| JBEngine |
Constructor
Parameters:
proto | The protocol used by the streams belonging to this engine |
~JBEngine ()
| ~JBEngine |
[virtual]
Destructor
inline Protocol protocol ()
| protocol |
[const]
Get the Jabber protocol this engine is using
Returns: The Jabber protocol as enumeration
inline const JabberID& componentServer ()
| componentServer |
[const]
Get the default component server
Returns: The default component server
inline void setAlternateDomain (const char* domain = 0)
| setAlternateDomain |
Set the alternate domain name
Parameters:
domain | Name of an acceptable alternate domain |
inline const JabberID& getAlternateDomain ()
| getAlternateDomain |
[const]
Get the alternate domain name
Returns: the alternate domain name
inline const String& defaultResource ()
| defaultResource |
[const]
Get the default resource name.
Returns: The default resource name.
inline const ObjList& streams ()
| streams |
[const]
Get the stream list
Returns: The list of streams belonging to this engine
void destruct ()
| destruct |
[virtual]
Cleanup streams. Stop all threads owned by this engine. Release memory
Reimplemented from GenObject.
void initialize (const NamedList& params)
| initialize |
[virtual]
Initialize the engine's parameters. Start private streams if requested
Parameters:
params | Engine's parameters |
void cleanup ()
| cleanup |
Terminate all streams
void setComponentServer (const char* domain)
| setComponentServer |
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
Parameters:
domain | Domain name of the server |
JBStream* findStream (const String& name)
| findStream |
Find a stream by its name. This method is thread safe
Parameters:
name | The name of the stream to find |
Returns: Referenced JBStream pointer or 0
JBStream* getStream (const JabberID* jid = 0, bool create = true)
| getStream |
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
Parameters:
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 |
Returns: Referenced JBStream pointer or 0
bool getStream (JBStream*& stream, bool& release)
| getStream |
Try to get a stream if stream parameter is 0
Parameters:
stream | Stream to check |
release | Set to true on exit if the caller must deref the stream |
Returns: True if stream is valid
JBClientStream* createClientStream (NamedList& params)
| createClientStream |
Create a new client stream. This method is thread safe
Parameters:
params | Stream parameters |
Returns: Referenced JBClientStream pointer or 0
bool receive ()
| receive |
Keep calling receive() for each stream until no data is received or the thread is terminated
Returns: True if data was received
bool process (u_int64_t time)
| process |
Get events from the streams owned by this engine and send them to a service. Delete them if not processed by a service
Parameters:
time | Current time |
Returns: True if an event was generated by any stream
bool checkDupId (const JBStream* stream)
| checkDupId |
Check if an outgoing stream exists with the same id and remote peer
Parameters:
stream | The calling stream |
Returns: True if found
bool checkComponentFrom (JBComponentStream* stream, const char* from)
| checkComponentFrom |
Check the 'from' attribute received by a Component stream at startup
Parameters:
stream | The calling stream |
from | The from attribute to check |
Returns: True if valid
void connect (JBStream* stream)
| connect |
[virtual]
Asynchronously call the connect method of the given stream if the stream is idle
Parameters:
stream | The stream to connect |
bool exiting ()
| exiting |
[const virtual]
Check if this engine is exiting
Returns: True is terminating
bool encryptStream (JBStream* stream)
| encryptStream |
[virtual]
Setup the transport layer security for a stream
Parameters:
stream | The stream requesting the operation |
Returns: True if stream securing started, false on failure.
void appendServer (XMPPServerInfo* server, bool open)
| appendServer |
Append a server info element to the list
Parameters:
server | The object to add |
open | True to open the stream, if in component mode |
bool getServerIdentity (String& destination, bool full, const char* token = 0,
bool domain = true)
| getServerIdentity |
Get the identity of the given server
Parameters:
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 |
Returns: False if server doesn't exists
XMPPServerInfo* findServerInfo (const char* token, bool domain)
| findServerInfo |
Find server info object
Parameters:
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 |
Returns: XMPPServerInfo pointer or 0 if not found
void attachService (JBService* service, Service type, int prio = -1)
| attachService |
Attach a service to this engine. This method is thread safe
Parameters:
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 |
void detachService (JBService* service)
| detachService |
Remove a service from all event handlers of this engine. This method is thread safe
Parameters:
service | The service to detach |
void printXml (const XMLElement& xml, const JBStream* stream, bool send)
| printXml |
[const]
Print an XML element to output
Parameters:
xml | Element to print |
stream | Stream requesting the operation |
send | True if sending, false if receiving |
inline const char* lookupProto (int proto, const char* def = 0)
| lookupProto |
[static]
Get the name of a protocol
Returns: The name of the requested protocol or the default value
inline int lookupProto (const char* proto, int def = 0)
| lookupProto |
[static]
Get the value associated with a protocol name
Returns: The value associated with a protocol name
Generated by: paulc on bussard on Mon Mar 8 12:18:15 2010, using kdoc 2.0a54. |