JBPresence Class Reference

A Jabber presence service. More...

#include <yatejabber.h>

Inheritance diagram for JBPresence:
JBService JBThreadList DebugEnabler Mutex GenObject Lockable

List of all members.

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 &params)
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)
XMPPUserRostergetRoster (const JabberID &jid, bool add, bool *added)
XMPPUsergetRemoteUser (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)
void cleanup ()

Static Public Member Functions

static XMLElementcreatePresence (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
JIDIdentitym_defIdentity
JIDFeatureList m_defFeatures

Static Protected Attributes

static TokenDict s_presence []

Friends

class XMPPUserRoster

Detailed Description

A Jabber presence service.

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


Member Enumeration Documentation

enum Presence

Presence type enumeration


Constructor & Destructor Documentation

JBPresence ( JBEngine engine,
const NamedList params,
int  prio = 0 
)

Constructor. Constructs a Jabber Component presence service

Parameters:
engine The Jabber engine
params Service's parameters
prio The priority of this service
virtual ~JBPresence (  )  [virtual]

Destructor


Member Function Documentation

virtual bool accept ( JBEvent event,
bool &  processed,
bool &  insert 
) [protected, virtual]

Accept an event from the engine

Parameters:
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
Returns:
False if not accepted, let the engine try another service

Reimplemented from JBService.

XMPPDirVal addOnPresence (  )  const [inline]

Get the 'add on presence' flags

Returns:
The 'add on presence' flags
XMPPDirVal addOnProbe (  )  const [inline]

Get the 'add on probe' flags

Returns:
The 'add on probe' flags
XMPPDirVal addOnSubscribe (  )  const [inline]

Get the 'add on subscribe' flags

Returns:
The 'add on subscribe' flags
bool autoRoster (  )  const [inline]

Check if this service should add new users when receiving presence, probe or subscribe

Returns:
True if should add a new user when receiving presence, probe or subscribe
XMPPDirVal autoSubscribe (  )  const [inline]

Get the auto subscribe parameter

Returns:
The auto subscribe parameter
virtual void checkTimeout ( u_int64_t  time  )  [virtual]

Check presence timeout This method is thread safe

Parameters:
time Current time
void cleanup (  ) 

Cleanup rosters

static XMLElement* createPresence ( const char *  from,
const char *  to,
Presence  type = None 
) [static]

Create an 'presence' element

Parameters:
from The 'from' attribute
to The 'to' attribute
type Presence type as enumeration
Returns:
A valid XMLElement pointer
static bool decodeError ( const XMLElement element,
String code,
String type,
String error 
) [static]

Decode an error element

Parameters:
element The XML element
code The 'code' attribute
type The 'type' attribute
error The name of the 'error' child
Returns:
False if 'element' is 0 or is not a presence one
bool delUnavailable (  )  const [inline]

Check if the unavailable resources must be deleted

Returns:
The delete unavailable parameter
u_int32_t expireInterval (  )  [inline]

Get the expire after probe interval

Returns:
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

Parameters:
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
Returns:
Referenced pointer or 0 if none
XMPPUserRoster* getRoster ( const JabberID jid,
bool  add,
bool *  added 
)

Get a roster. Add a new one if requested. This method is thread safe

Parameters:
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
Returns:
Referenced pointer or 0 if none
bool ignoreNonRoster (  )  const [inline]

Check if this service should ignore destination users not in roster

Returns:
True if non existent destinations should be ignored
virtual void initialize ( const NamedList params  )  [virtual]

Initialize the presence service

Parameters:
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

Parameters:
user The new user
virtual void notifyPresence ( XMPPUser user,
JIDResource resource 
) [virtual]

Notify on state/capabilities change

Parameters:
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)

Parameters:
event The event with the element
available The availability of the remote user
Returns:
False to send item-not-found error
virtual bool notifyProbe ( JBEvent event  )  [virtual]

Notify on probe request with users we don't know about

Parameters:
event The event with the element
Returns:
False to send item-not-found error
virtual void notifySubscribe ( XMPPUser user,
Presence  presence 
) [virtual]

Notify on subscribe event

Parameters:
user The user that received the event
presence Presence type: Subscribe,Subscribed,Unsubscribe,Unsubscribed
virtual bool notifySubscribe ( JBEvent event,
Presence  presence 
) [virtual]

Notify on subscribe event with users we don't know about

Parameters:
event The event with the element
presence Presence type: Subscribe,Subscribed,Unsubscribe,Unsubscribed
Returns:
False to send item-not-found error
static const char* presenceText ( Presence  presence  )  [inline, static]

Get the text from a presence type

Parameters:
presence The presence type
Returns:
The associated text or 0

References TelEngine::lookup().

static Presence presenceType ( const char *  text  )  [inline, static]

Get the type of a 'presence' stanza as enumeration

Parameters:
text The text to check
Returns:
Presence type as enumeration

References TelEngine::lookup().

u_int32_t probeInterval (  )  [inline]

Get the probe interval. Time to send a probe if nothing was received from that user

Returns:
The probe interval
virtual bool process (  )  [virtual]

Process an event from the receiving list This method is thread safe

Returns:
False if the list is empty
virtual void processDisco ( JBEvent event  )  [virtual]

Process disco info elements

Parameters:
event The event with the element
virtual void processError ( JBEvent event  )  [virtual]

Process a presence error element

Parameters:
event The event with the element
virtual void processPresence ( JBEvent event  )  [virtual]

Process a presence element

Parameters:
event The event with the element
virtual void processProbe ( JBEvent event  )  [virtual]

Process a presence probe element

Parameters:
event The event with the element
virtual void processSubscribe ( JBEvent event,
Presence  presence 
) [virtual]

Process a presence subscribe element

Parameters:
event The event with the element
presence Presence type: Subscribe,Subscribed,Unsubscribe,Unsubscribed
virtual void processUnavailable ( JBEvent event  )  [virtual]

Process a presence unavailable element

Parameters:
event The event with the element
void removeRemoteUser ( const JabberID local,
const JabberID remote 
)

Remove a remote peer of a local one This method is thread safe

Parameters:
local The local peer
remote The remote peer
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)

Parameters:
element Element to send
stream The stream to send through
Returns:
The result of send operation. False if element is 0
bool validDomain ( const String domain  ) 

Check if the given domain is a valid (known) one

Parameters:
domain The domain name to check
Returns:
True if the given domain is a valid one

The documentation for this class was generated from the following file:
Generated on Thu Apr 8 18:22:38 2010 for Yate by  doxygen 1.6.3