#include <yatejabber.h>
Public Types | |
enum | Presence { Error = 0, Probe = 1, Subscribe = 2, Subscribed = 3, Unavailable = 4, Unsubscribe = 5, Unsubscribed = 6, None = 7 } |
Public Member Functions | |
JBPresence (JBEngine *engine, const NamedList *params, int prio=0) | |
virtual | ~JBPresence () |
XMPPDirVal | autoSubscribe () const |
bool | delUnavailable () const |
XMPPDirVal | addOnSubscribe () const |
XMPPDirVal | addOnProbe () const |
XMPPDirVal | addOnPresence () const |
bool | autoRoster () const |
bool | ignoreNonRoster () const |
u_int32_t | probeInterval () |
u_int32_t | expireInterval () |
virtual void | initialize (const NamedList ¶ms) |
virtual bool | process () |
virtual void | checkTimeout (u_int64_t time) |
virtual void | processDisco (JBEvent *event) |
virtual void | processError (JBEvent *event) |
virtual void | processProbe (JBEvent *event) |
virtual void | processSubscribe (JBEvent *event, Presence presence) |
virtual void | processUnavailable (JBEvent *event) |
virtual void | processPresence (JBEvent *event) |
virtual bool | notifyProbe (JBEvent *event) |
virtual bool | notifySubscribe (JBEvent *event, Presence presence) |
virtual void | notifySubscribe (XMPPUser *user, Presence presence) |
virtual bool | notifyPresence (JBEvent *event, bool available) |
virtual void | notifyPresence (XMPPUser *user, JIDResource *resource) |
virtual void | notifyNewUser (XMPPUser *user) |
XMPPUserRoster * | getRoster (const JabberID &jid, bool add, bool *added) |
XMPPUser * | getRemoteUser (const JabberID &local, const JabberID &remote, bool addLocal, bool *addedLocal, bool addRemote, bool *addedRemote) |
void | removeRemoteUser (const JabberID &local, const JabberID &remote) |
bool | validDomain (const String &domain) |
bool | sendStanza (XMLElement *element, JBStream *stream) |
bool | sendError (XMPPError::Type type, const String &from, const String &to, XMLElement *element, JBStream *stream=0, const String *id=0) |
void | cleanup () |
Static Public Member Functions | |
static XMLElement * | createPresence (const char *from, const char *to, Presence type=None) |
static bool | decodeError (const XMLElement *element, String &code, String &type, String &error) |
static Presence | presenceType (const char *text) |
static const char * | presenceText (Presence presence) |
Protected Member Functions | |
virtual bool | accept (JBEvent *event, bool &processed, bool &insert) |
Protected Attributes | |
XMPPDirVal | m_autoSubscribe |
bool | m_delUnavailable |
bool | m_autoRoster |
bool | m_ignoreNonRoster |
XMPPDirVal | m_addOnSubscribe |
XMPPDirVal | m_addOnProbe |
XMPPDirVal | m_addOnPresence |
bool | m_autoProbe |
u_int32_t | m_probeInterval |
u_int32_t | m_expireInterval |
ObjList | m_rosters |
JIDIdentity * | m_defIdentity |
JIDFeatureList | m_defFeatures |
Static Protected Attributes | |
static TokenDict | s_presence [] |
Friends | |
class | XMPPUserRoster |
This class is a presence service for Jabber engine. Handle presence stanzas and iq query info or items with destination containing a node and a valid domain
enum Presence |
Presence type enumeration
JBPresence | ( | JBEngine * | engine, | |
const NamedList * | params, | |||
int | prio = 0 | |||
) |
Constructor. Constructs a Jabber Component presence service
engine | The Jabber engine | |
params | Service's parameters | |
prio | The priority of this service |
virtual ~JBPresence | ( | ) | [virtual] |
Destructor
virtual bool accept | ( | JBEvent * | event, | |
bool & | processed, | |||
bool & | insert | |||
) | [protected, virtual] |
Accept an event from the engine
event | The event to accept | |
processed | Set to true on exit to signal that the event was already processed | |
insert | Set to true if accepted to insert on top of the event queue |
Reimplemented from JBService.
XMPPDirVal addOnPresence | ( | ) | const [inline] |
Get the 'add on presence' flags
XMPPDirVal addOnProbe | ( | ) | const [inline] |
Get the 'add on probe' flags
XMPPDirVal addOnSubscribe | ( | ) | const [inline] |
Get the 'add on subscribe' flags
bool autoRoster | ( | ) | const [inline] |
Check if this service should add new users when receiving presence, probe or subscribe
XMPPDirVal autoSubscribe | ( | ) | const [inline] |
Get the auto subscribe parameter
virtual void checkTimeout | ( | u_int64_t | time | ) | [virtual] |
Check presence timeout This method is thread safe
time | Current time |
void cleanup | ( | ) |
Cleanup rosters
static XMLElement* createPresence | ( | const char * | from, | |
const char * | to, | |||
Presence | type = None | |||
) | [static] |
Create an 'presence' element
from | The 'from' attribute | |
to | The 'to' attribute | |
type | Presence type as enumeration |
static bool decodeError | ( | const XMLElement * | element, | |
String & | code, | |||
String & | type, | |||
String & | error | |||
) | [static] |
Decode an error element
element | The XML element | |
code | The 'code' attribute | |
type | The 'type' attribute | |
error | The name of the 'error' child |
bool delUnavailable | ( | ) | const [inline] |
Check if the unavailable resources must be deleted
u_int32_t expireInterval | ( | ) | [inline] |
Get the expire after probe interval
XMPPUser* getRemoteUser | ( | const JabberID & | local, | |
const JabberID & | remote, | |||
bool | addLocal, | |||
bool * | addedLocal, | |||
bool | addRemote, | |||
bool * | addedRemote | |||
) |
Get a remote peer of a local one. Add a new one if requested. This method is thread safe
local | The local peer | |
remote | The remote peer | |
addLocal | True to add the local user if doesn't exists | |
addedLocal | Optional parameter to be set if a new local user was added | |
addRemote | True to add the remote user if doesn't exists | |
addedRemote | Optional parameter to be set if a new remote user was added |
XMPPUserRoster* getRoster | ( | const JabberID & | jid, | |
bool | add, | |||
bool * | added | |||
) |
Get a roster. Add a new one if requested. This method is thread safe
jid | The user's jid | |
add | True to add the user if doesn't exists | |
added | Optional parameter to be set if a new user was added |
bool ignoreNonRoster | ( | ) | const [inline] |
Check if this service should ignore destination users not in roster
virtual void initialize | ( | const NamedList & | params | ) | [virtual] |
Initialize the presence service
params | Service's parameters |
Reimplemented from JBService.
virtual void notifyNewUser | ( | XMPPUser * | user | ) | [virtual] |
Notify when a new user is added Used basically to add a local resource
user | The new user |
virtual void notifyPresence | ( | XMPPUser * | user, | |
JIDResource * | resource | |||
) | [virtual] |
Notify on state/capabilities change
user | The user that received the event | |
resource | The resource that changet its state or capabilities |
virtual bool notifyPresence | ( | JBEvent * | event, | |
bool | available | |||
) | [virtual] |
Notify on presence event with users we don't know about or presence unavailable received without resource (the remote user is entirely unavailable)
event | The event with the element | |
available | The availability of the remote user |
virtual bool notifyProbe | ( | JBEvent * | event | ) | [virtual] |
Notify on probe request with users we don't know about
event | The event with the element |
Notify on subscribe event
user | The user that received the event | |
presence | Presence type: Subscribe,Subscribed,Unsubscribe,Unsubscribed |
Notify on subscribe event with users we don't know about
event | The event with the element | |
presence | Presence type: Subscribe,Subscribed,Unsubscribe,Unsubscribed |
static const char* presenceText | ( | Presence | presence | ) | [inline, static] |
Get the text from a presence type
presence | The presence type |
References TelEngine::lookup().
static Presence presenceType | ( | const char * | text | ) | [inline, static] |
Get the type of a 'presence' stanza as enumeration
text | The text to check |
References TelEngine::lookup().
u_int32_t probeInterval | ( | ) | [inline] |
Get the probe interval. Time to send a probe if nothing was received from that user
virtual bool process | ( | ) | [virtual] |
Process an event from the receiving list This method is thread safe
virtual void processDisco | ( | JBEvent * | event | ) | [virtual] |
Process disco info elements
event | The event with the element |
virtual void processError | ( | JBEvent * | event | ) | [virtual] |
Process a presence error element
event | The event with the element |
virtual void processPresence | ( | JBEvent * | event | ) | [virtual] |
Process a presence element
event | The event with the element |
virtual void processProbe | ( | JBEvent * | event | ) | [virtual] |
Process a presence probe element
event | The event with the element |
Process a presence subscribe element
event | The event with the element | |
presence | Presence type: Subscribe,Subscribed,Unsubscribe,Unsubscribed |
virtual void processUnavailable | ( | JBEvent * | event | ) | [virtual] |
Process a presence unavailable element
event | The event with the element |
Remove a remote peer of a local one This method is thread safe
local | The local peer | |
remote | The remote peer |
bool sendError | ( | XMPPError::Type | type, | |
const String & | from, | |||
const String & | to, | |||
XMLElement * | element, | |||
JBStream * | stream = 0 , |
|||
const String * | id = 0 | |||
) |
Send an error. Error type is 'modify'. If id is 0 sent element will be of type 'presence'. Otherwise: 'iq'
type | The error | |
from | The from attribute | |
to | The to attribute | |
element | The element that generated the error | |
stream | Optional stream to use | |
id | Optional id. If present (even if empty) the error element will be of type 'iq' |
bool sendStanza | ( | XMLElement * | element, | |
JBStream * | stream | |||
) |
Send an element through the given stream. If the stream is 0 try to get one from the engine. In any case the element is consumed (deleted)
element | Element to send | |
stream | The stream to send through |
bool validDomain | ( | const String & | domain | ) |
Check if the given domain is a valid (known) one
domain | The domain name to check |