tigase.xmpp.impl

## Class Presence

- java.lang.Object
- - tigase.xmpp.XMPPProcessor
  - - tigase.xmpp.impl.Presence

- All Implemented Interfaces:
    Comparable<XMPPImplIfc>, XMPPImplIfc, XMPPProcessorIfc, XMPPStopListenerIfc

      public class Presence
      extends XMPPProcessor
      implements XMPPProcessorIfc, XMPPStopListenerIfc

  Class responsible for handling Presence packets
  Author:
    Artur Hefczyc

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Presence.ExtendedPresenceProcessorIfc`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `AUTO_AUTHORIZE_PROP_KEY` key allowing enabling automatic authorisation.
    `static String` | `DIRECT_PRESENCE` `DIRECT_PRESENCE` is a key in temporary session data for the collection of JIDs where direct presence was sent.
    `static String` | `DISABLE_ROSTER_LAZY_LOADING_KEY`
    `static String` | `EXTENDED_PRESENCE_PROCESSORS_KEY`
    `static String` | `OFFLINE_BUD_SENT` Field description
    `static String` | `OFFLINE_RES_SENT` Field description
    `static String` | `OFFLINE_ROSTER_LAST_SEEN_PROP_KEY` Field description
    `static String` | `PRESENCE_ELEMENT_NAME` Field description
    `static String` | `PRESENCE_GLOBAL_FORWARD` key allowing setting global forwarding JID address.
    `protected RosterAbstract` | `roster_util` Field description
    `static String` | `SKIP_OFFLINE_PROP_KEY` Field description
    `static String` | `SKIP_OFFLINE_SYS_PROP_KEY` Field description
    `static String` | `USERS_STATUS_CHANGES` Field description
    `protected static String` | `XMLNS` Field description

    - ### Fields inherited from class tigase.xmpp.XMPPProcessor

      `ALL_NAMES, ALL_PATHS, cmpInfo`

    - ### Fields inherited from interface tigase.xmpp.XMPPImplIfc

      `CLIENT_XMLNS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Presence()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addDirectPresenceJID(tigase.xmpp.JID jid, XMPPResourceConnection session)` Add JID to collection of JIDs to which direct presence was sent.
    `protected static void` | `broadcastDirectPresences(StanzaType t, XMPPResourceConnection session, Queue<Packet> results, tigase.xml.Element pres)` `broadcastDirectPresences` broadcast a direct Presence from provided `pres` `Element` object to the collection of JIDs stored in temporary session data under key `DIRECT_PRESENCE`.
    `static void` | `broadcastOffline(XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract roster_util)` `sendPresenceBroadcast` method broadcasts given presence to all buddies from roster and to all users to which direct presence was sent.
    `void` | `broadcastProbe(XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings)` `sendPresenceBroadcast` method broadcasts given presence to all buddies from roster and to all users to which direct presence was sent.
    `protected void` | `buddyOnline(XMPPResourceConnection session, tigase.xmpp.JID buddy, Queue<Packet> results, boolean online)` Method sends back presence to contact while it becomes online (i.e.
    `int` | `concurrentQueuesNo()` Methods returns a preferable number of threads/packets queues for the plugin.
    `protected static void` | `forwardPresence(Queue<Packet> results, Packet packet, tigase.xmpp.JID from)` Simply forwards packet to the destination
    `protected static RosterAbstract` | `getRosterUtil()` Returns shared instance of class implementing `RosterAbstract` - either default one (`RosterFlat`) or the one configured with "roster-implementation" property.
    `void` | `getStatistics(StatisticsList list)` The method allows to retrieve plugin own statistics if it generates any.
    `String` | `id()` Method `id` returns a unique ID of the plugin.
    `void` | `init(Map<String,Object> settings)` Method `init` is called just after the plugin has been loaded into memory.
    `void` | `process(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, Map<String,Object> settings)` Performs processing of presence packets and calls different methods for particular `RosterAbstract.PresenceType`
    `protected void` | `processError(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType presenceType)` Process presence stanza of type Error.
    `protected void` | `processInInitial(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType presenceType)` Method is responsible for processing incoming initial presence (i.e.
    `protected void` | `processInProbe(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType presenceType)` Method is responsible for processing incoming presence probe (i.e.
    `protected void` | `processInSubscribe(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming subscription request (i.e.
    `protected void` | `processInSubscribed(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming subscribed presence (i.e.
    `protected void` | `processInUnsubscribe(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming unsubscribe presence (i.e.
    `protected void` | `processInUnsubscribed(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing incoming unsubscribed presence (i.e.
    `protected void` | `processOutInitial(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType type)` Method is responsible for processing outgoing initial presence (i.e.
    `protected void` | `processOutSubscribe(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing outgoing subscribe and unsubscribe presence (i.e.
    `protected void` | `processOutSubscribed(Packet packet, XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings, RosterAbstract.PresenceType pres_type)` Method is responsible for processing outgoing subscribed and unsubscribed presence (i.e.
    `static void` | `rebroadcastPresence(XMPPResourceConnection session, Queue<Packet> results)`
    `static void` | `removeDirectPresenceJID(tigase.xmpp.JID jid, XMPPResourceConnection session)` Remove JID from collection of JIDs to which direct presence was sent.
    `void` | `resendPendingInRequests(XMPPResourceConnection session, Queue<Packet> results)` Sends out all pending subscription request during user log-in.
    `static void` | `sendPresence(StanzaType t, tigase.xmpp.BareJID from, tigase.xmpp.BareJID to, Queue<Packet> results, tigase.xml.Element pres)` Sends Presence stanza from provided parameters without returning created result `Packet` object.
    `static Packet` | `sendPresence(StanzaType t, tigase.xmpp.JID from, tigase.xmpp.JID to, Queue<Packet> results, tigase.xml.Element pres)` Sends Presence stanza from provided parameters as well as returns created result `Packet` object.
    `static void` | `sendPresenceBroadcast(StanzaType t, XMPPResourceConnection session, EnumSet<RosterAbstract.SubscriptionType> subscrs, Queue<Packet> results, tigase.xml.Element pres, Map<String,Object> settings, RosterAbstract roster_util)` `sendPresenceBroadcast` method broadcasts given presence to all buddies from roster and to all users to which direct presence was sent.
    `protected void` | `sendRosterOfflinePresence(XMPPResourceConnection session, Queue<Packet> results)` Method sends server generated presence unavailable for all buddies from the roster with a custom status message.
    `void` | `stopped(XMPPResourceConnection session, Queue<Packet> results, Map<String,Object> settings)` Performs additional processing upon closing user session (user either disconnects or logs-out).
    `String[][]` | `supElementNamePaths()` Method `supElementNamePaths` returns an array of element names in form of a full path to the XML element for stanzas which can be processed by this plugin.
    `String[]` | `supNamespaces()` Method `supNamespaces` returns an array of name-spaces for stanzas which can be processed by this plugin.
    `protected static void` | `updateOfflineChange(XMPPResourceConnection session, Queue<Packet> results)` `updateOfflineChange` method broadcast off-line presence to all other user active resources.
    `static void` | `updatePresenceChange(Packet presence, XMPPResourceConnection session, Queue<Packet> results)` `updatePresenceChange` method is used to broadcast to all active resources presence stanza received from other users, like incoming availability presence, subscription presence and so on...
    `protected static void` | `updateResourcesAvailable(XMPPResourceConnection session, StanzaType type, Packet packet)` Method updates resources information upon receiving initial availability presence (type available or missing type)
    `static void` | `updateUserResources(tigase.xml.Element presence, XMPPResourceConnection session, Queue<Packet> results, boolean initial)` `updateUserResources` method is used to broadcast to all other resources presence stanza from one user resource.

    - ### Methods inherited from class tigase.xmpp.XMPPProcessor

      `canHandle, compareTo, concurrentThreadsPerQueue, getComponentInfo, getInstance, isSupporting, supDiscoFeatures, supElements, supStreamFeatures, supTypes, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface tigase.xmpp.XMPPImplIfc

      `canHandle, concurrentThreadsPerQueue, getComponentInfo, isSupporting, supDiscoFeatures, supElements, supStreamFeatures, supTypes`

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

- - ### Field Detail

    - #### AUTO_AUTHORIZE_PROP_KEY

          public static final String AUTO_AUTHORIZE_PROP_KEY

      key allowing enabling automatic authorisation.
      See Also:
        Constant Field Values

    - #### DIRECT_PRESENCE

          public static final String DIRECT_PRESENCE

      `DIRECT_PRESENCE` is a key in temporary session data for the collection of JIDs where direct presence was sent. To all these addresses unavailable presence must be sent when user disconnects.
      See Also:
        Constant Field Values

    - #### DISABLE_ROSTER_LAZY_LOADING_KEY

          public static final String DISABLE_ROSTER_LAZY_LOADING_KEY

      See Also:
        Constant Field Values

    - #### EXTENDED_PRESENCE_PROCESSORS_KEY

          public static final String EXTENDED_PRESENCE_PROCESSORS_KEY

      See Also:
        Constant Field Values

    - #### OFFLINE_BUD_SENT

          public static final String OFFLINE_BUD_SENT

      Field description
      See Also:
        Constant Field Values

    - #### OFFLINE_RES_SENT

          public static final String OFFLINE_RES_SENT

      Field description
      See Also:
        Constant Field Values

    - #### OFFLINE_ROSTER_LAST_SEEN_PROP_KEY

          public static final String OFFLINE_ROSTER_LAST_SEEN_PROP_KEY

      Field description
      See Also:
        Constant Field Values

    - #### PRESENCE_ELEMENT_NAME

          public static final String PRESENCE_ELEMENT_NAME

      Field description
      See Also:
        Constant Field Values

    - #### PRESENCE_GLOBAL_FORWARD

          public static final String PRESENCE_GLOBAL_FORWARD

      key allowing setting global forwarding JID address.
      See Also:
        Constant Field Values

    - #### SKIP_OFFLINE_PROP_KEY

          public static final String SKIP_OFFLINE_PROP_KEY

      Field description
      See Also:
        Constant Field Values

    - #### SKIP_OFFLINE_SYS_PROP_KEY

          public static final String SKIP_OFFLINE_SYS_PROP_KEY

      Field description
      See Also:
        Constant Field Values

    - #### USERS_STATUS_CHANGES

          public static final String USERS_STATUS_CHANGES

      Field description
      See Also:
        Constant Field Values

    - #### XMLNS

          protected static final String XMLNS

      Field description
      See Also:
        Constant Field Values

    - #### roster_util

          protected RosterAbstract roster_util

      Field description

  - ### Constructor Detail

    - #### Presence

          public Presence()

  - ### Method Detail

    - #### addDirectPresenceJID

          public static void addDirectPresenceJID(tigase.xmpp.JID jid,
                                                  XMPPResourceConnection session)

      Add JID to collection of JIDs to which direct presence was sent. To all these addresses unavailable presence must be sent when user disconnects.
      Parameters:
        `jid` - to which direct presence was sent.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.

    - #### broadcastOffline

          public static void broadcastOffline(XMPPResourceConnection session,
                                              Queue<Packet> results,
                                              Map<String,Object> settings,
                                              RosterAbstract roster_util)
                                       throws NotAuthorizedException,
                                              TigaseDBException

      `sendPresenceBroadcast` method broadcasts given presence to all buddies from roster and to all users to which direct presence was sent.
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `roster_util` - instance of class implementing `RosterAbstract`.
      Throws:
        `NotAuthorizedException` - if an error occurs
        `TigaseDBException`

    - #### broadcastProbe

          public void broadcastProbe(XMPPResourceConnection session,
                                     Queue<Packet> results,
                                     Map<String,Object> settings)
                              throws NotAuthorizedException,
                                     TigaseDBException

      `sendPresenceBroadcast` method broadcasts given presence to all buddies from roster and to all users to which direct presence was sent. Before sending presence method calls `requiresPresenceSending()`, configured to only check local environment status (if enabled) to verify whether presence needs to be sent.
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
      Throws:
        `NotAuthorizedException` - if an error occurs
        `TigaseDBException`

    - #### concurrentQueuesNo

          public int concurrentQueuesNo()

      Description copied from interface: `XMPPImplIfc`
      Methods returns a preferable number of threads/packets queues for the plugin. This number can be overwritten through configuration settings, however, a default value should be reasonably good for most standard installations. It is recommended to assign at least as much as twice a number of CPUs cores for I/O bound processing and number a number equal to CPUs cores for fast processing not slowed down by any I/O.
      Specified by:
        `concurrentQueuesNo` in interface `XMPPImplIfc`
      Overrides:
        `concurrentQueuesNo` in class `XMPPProcessor`
      Returns:
        an integer preferred number of processing threads for the plugin.

    - #### id

          public String id()

      Description copied from interface: `XMPPImplIfc`
      Method `id` returns a unique ID of the plugin. Each plugin has own, unique ID which is used in the configuration file to determine whether it needs to be loaded or not. In most cases the ID can be equal to XMLNS of the packages processed by the plugin.
      Specified by:
        `id` in interface `XMPPImplIfc`
      Returns:
        a `String` value

    - #### init

          public void init(Map<String,Object> settings)
                    throws TigaseDBException

      Description copied from interface: `XMPPImplIfc`
      Method `init` is called just after the plugin has been loaded into memory. The idea behind this is to allow it to initialize or check the database. This might be especially useful for plugins which want to have a database access via non-standard stored procedures or need schema upgrade.
      Specified by:
        `init` in interface `XMPPImplIfc`
      Overrides:
        `init` in class `XMPPProcessor`
      Parameters:
        `settings` - is a Map with initial processor settings from the configuration file.
      Throws:
        `TigaseDBException`

    - #### process

          public void process(Packet packet,
                              XMPPResourceConnection session,
                              NonAuthUserRepository repo,
                              Queue<Packet> results,
                              Map<String,Object> settings)
                       throws XMPPException

      Performs processing of presence packets and calls different methods for particular `RosterAbstract.PresenceType`
      Specified by:
        `process` in interface `XMPPProcessorIfc`
      Parameters:
        `packet` - packet is which being processed. This parameter may never be null. Even though this is not immutable object it mustn't be altered. None of it's fields or attributes can be changed during processing.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data. It allows for storing information in a permanent storage or in memory only during the live of the online session. This parameter can be null if there is no online user session at the time of the packet processing.
        `repo` - this is a user data storage which is normally used when the user session (parameter above) is null. This is repository allows for a very restricted access only. It allows for storing some user private data (doesn't allow overwriting existing data) like messages for offline users and it also allows for reading user public data like VCard.
        `results` - this a collection with packets which have been generated as input packet processing results. Regardless a response to a user request is sent or the packet is forwarded to it's destination it is always required that a copy of the input packet is created and stored in the results queue.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration. In most cases it is unused, however if the plugin needs to access an external database that this is a way to pass database connection string to the plugin.
      Throws:
        `XMPPException`

    - #### removeDirectPresenceJID

          public static void removeDirectPresenceJID(tigase.xmpp.JID jid,
                                                     XMPPResourceConnection session)

      Remove JID from collection of JIDs to which direct presence was sent.
      Parameters:
        `jid` - to which direct presence was sent.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.

    - #### resendPendingInRequests

          public void resendPendingInRequests(XMPPResourceConnection session,
                                              Queue<Packet> results)
                                       throws NotAuthorizedException,
                                              TigaseDBException

      Sends out all pending subscription request during user log-in.
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### sendPresence

          public static void sendPresence(StanzaType t,
                                          tigase.xmpp.BareJID from,
                                          tigase.xmpp.BareJID to,
                                          Queue<Packet> results,
                                          tigase.xml.Element pres)

      Sends Presence stanza from provided parameters without returning created result `Packet` object. In case of missing `pres` parameter a Presence stanza will be created with provided `StanzaType` type `t`, `JID` type `from` and `JID` type `to`. Otherwise Presence stanza `pres` will be cloned and `to` attribute will be set from parameter `to`.
      Parameters:
        `t` - specifies type of the presence to be send.
        `from` - is a `JID` instance with stanza source address.
        `to` - is a `JID` instance with stanza destination address.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `pres` - an Object of type `Element` holding Presence stanza to be sent.

    - #### sendPresence

          public static Packet sendPresence(StanzaType t,
                                            tigase.xmpp.JID from,
                                            tigase.xmpp.JID to,
                                            Queue<Packet> results,
                                            tigase.xml.Element pres)

      Sends Presence stanza from provided parameters as well as returns created result `Packet` object. In case of missing `pres` parameter a Presence stanza will be created with provided `StanzaType` type `t`, `JID` type `from` and `JID` type `to`. Otherwise Presence stanza `pres` will be cloned and `to` attribute will be set from parameter `to`.
      Parameters:
        `t` - specifies type of the presence to be send.
        `from` - is a `JID` instance with stanza source address.
        `to` - is a `JID` instance with stanza destination address.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `pres` - an Object of type `Element` holding Presence stanza to be sent.
      Returns:
        an instance of `Packet` holding Presence stanza created from provided parameters.

    - #### sendPresenceBroadcast

          public static void sendPresenceBroadcast(StanzaType t,
                                                   XMPPResourceConnection session,
                                                   EnumSet<RosterAbstract.SubscriptionType> subscrs,
                                                   Queue<Packet> results,
                                                   tigase.xml.Element pres,
                                                   Map<String,Object> settings,
                                                   RosterAbstract roster_util)
                                            throws NotAuthorizedException,
                                                   TigaseDBException

      `sendPresenceBroadcast` method broadcasts given presence to all buddies from roster and to all users to which direct presence was sent. Before sending presence method calls `requiresPresenceSending()` performing, if configured, both system and roster check to verify whether presence needs to be sent.
      Parameters:
        `t` - specifies type of the presence to be send.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `subscrs` - an `EnumSet<SubscriptionType>` holding all `RosterAbstract.SubscriptionType` to which a Presence should be broadcast.
        `pres` - an Object of type `Element` holding Presence stanza to be sent.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `roster_util` - instance of class implementing `RosterAbstract`.
      Throws:
        `NotAuthorizedException` - if an error occurs
        `TigaseDBException`

    - #### stopped

          public void stopped(XMPPResourceConnection session,
                              Queue<Packet> results,
                              Map<String,Object> settings)

      Description copied from interface: `XMPPStopListenerIfc`
      Performs additional processing upon closing user session (user either disconnects or logs-out).
      Specified by:
        `stopped` in interface `XMPPStopListenerIfc`
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data. It allows for storing information in a permanent storage or in memory only during the live of the online session. This parameter can be null if there is no online user session at the time of the packet processing.
        `results` - this a collection with packets which have been generated as input packet processing results. Regardless a response to a user request is sent or the packet is forwarded to it's destination it is always required that a copy of the input packet is created and stored in the results queue.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration. In most cases it is unused, however if the plugin needs to access an external database that this is a way to pass database connection string to the plugin.

    - #### supElementNamePaths

          public String[][] supElementNamePaths()

      Description copied from interface: `XMPPImplIfc`
      Method `supElementNamePaths` returns an array of element names in form of a full path to the XML element for stanzas which can be processed by this plugin. Each element name path corresponds to XMLNS returned in array by `supNamespaces()` method. The element path itself is represented by a String array with each path element as a separate String.
      Specified by:
        `supElementNamePaths` in interface `XMPPImplIfc`
      Overrides:
        `supElementNamePaths` in class `XMPPProcessor`
      Returns:
        a `String[][]` value is an array for element paths for which the plugin offers processing capabilities. Each path is in form of a String array in order to reduce parsing overhead.

    - #### supNamespaces

          public String[] supNamespaces()

      Description copied from interface: `XMPPImplIfc`
      Method `supNamespaces` returns an array of name-spaces for stanzas which can be processed by this plugin. Each namespace corresponds to element name returned in array by `supElemenets()` method.
      Specified by:
        `supNamespaces` in interface `XMPPImplIfc`
      Overrides:
        `supNamespaces` in class `XMPPProcessor`
      Returns:
        a `String[]` value

    - #### rebroadcastPresence

          public static void rebroadcastPresence(XMPPResourceConnection session,
                                                 Queue<Packet> results)
                                          throws NotAuthorizedException,
                                                 TigaseDBException

      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### updatePresenceChange

          public static void updatePresenceChange(Packet presence,
                                                  XMPPResourceConnection session,
                                                  Queue<Packet> results)
                                           throws NotAuthorizedException

      `updatePresenceChange` method is used to broadcast to all active resources presence stanza received from other users, like incoming availability presence, subscription presence and so on... Initial presences are however sent only to those resources which already have sent initial presence.
      Parameters:
        `presence` - an `Element` presence received from other users, we have to change 'to' attribute to full resource JID.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
      Throws:
        `NotAuthorizedException` - if an error occurs

    - #### updateUserResources

          public static void updateUserResources(tigase.xml.Element presence,
                                                 XMPPResourceConnection session,
                                                 Queue<Packet> results,
                                                 boolean initial)
                                          throws NotAuthorizedException

      `updateUserResources` method is used to broadcast to all other resources presence stanza from one user resource. So if new resource connects this method updates presence information about new resource to old resources and about old resources to new resource.
      Parameters:
        `presence` - an `Element` presence received from other users, we have to change 'to' attribute to full resource JID.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `initial` - specifies whether this is an initial presence or not (i.e. if there is a presence data from the presence stored within user session object or not)
      Throws:
        `NotAuthorizedException` - if an error occurs

    - #### getStatistics

          public void getStatistics(StatisticsList list)

      Description copied from interface: `XMPPImplIfc`
      The method allows to retrieve plugin own statistics if it generates any.
      Specified by:
        `getStatistics` in interface `XMPPImplIfc`
      Overrides:
        `getStatistics` in class `XMPPProcessor`
      Parameters:
        `list` - is a statistics collection to which plugins own metrics can be added.

    - #### broadcastDirectPresences

          protected static void broadcastDirectPresences(StanzaType t,
                                                         XMPPResourceConnection session,
                                                         Queue<Packet> results,
                                                         tigase.xml.Element pres)
                                                  throws NotAuthorizedException,
                                                         TigaseDBException

      `broadcastDirectPresences` broadcast a direct Presence from provided `pres` `Element` object to the collection of JIDs stored in temporary session data under key `DIRECT_PRESENCE`.
      Parameters:
        `t` - specifies type of the presence to be send.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `pres` - an Object of type `Element` holding Presence stanza to be sent.
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### buddyOnline

          protected void buddyOnline(XMPPResourceConnection session,
                                     tigase.xmpp.JID buddy,
                                     Queue<Packet> results,
                                     boolean online)
                              throws NotAuthorizedException,
                                     TigaseDBException

      Method sends back presence to contact while it becomes online (i.e. during processing of incoming initial presence of the contact/buddy)
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `buddy` - `JID` of a roster element for which an online state will be set
        `results` - this a collection with packets which have been generated as input packet processing results.
        `online` - set whether given contact is online or offline
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### forwardPresence

          protected static void forwardPresence(Queue<Packet> results,
                                                Packet packet,
                                                tigase.xmpp.JID from)

      Simply forwards packet to the destination
      Parameters:
        `results` - this a collection with packets which have been generated as input packet processing results.
        `packet` - to forward
        `from` - is a `JID` instance with stanza source address.

    - #### processError

          protected void processError(Packet packet,
                                      XMPPResourceConnection session,
                                      Queue<Packet> results,
                                      Map<String,Object> settings,
                                      RosterAbstract.PresenceType presenceType)
                               throws NotAuthorizedException,
                                      TigaseDBException,
                                      NoConnectionIdException

      Process presence stanza of type Error. Allows errors sent from server to user and ignore presence errors sent from the user.
      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `presenceType` - specifies type of the presence
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processInInitial

          protected void processInInitial(Packet packet,
                                          XMPPResourceConnection session,
                                          Queue<Packet> results,
                                          Map<String,Object> settings,
                                          RosterAbstract.PresenceType presenceType)
                                   throws NoConnectionIdException,
                                          NotAuthorizedException,
                                          TigaseDBException

      Method is responsible for processing incoming initial presence (i.e. in the receivers session manager).

      It validates the packet (whether from is present or if it's a direct presence to existing resource) and subsequently set received presence for the contact that sent it.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `presenceType` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processInProbe

          protected void processInProbe(Packet packet,
                                        XMPPResourceConnection session,
                                        Queue<Packet> results,
                                        Map<String,Object> settings,
                                        RosterAbstract.PresenceType presenceType)
                                 throws NotAuthorizedException,
                                        TigaseDBException,
                                        PacketErrorTypeException

      Method is responsible for processing incoming presence probe (i.e. in the receivers session manager).

      It validates whether the packet comes from a contact that has correct subscription and responds with presence of all user's resources presences.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `presenceType` - specifies type of the presence.
      Throws:
        `NotAuthorizedException`
        `PacketErrorTypeException`
        `TigaseDBException`

    - #### processInSubscribe

          protected void processInSubscribe(Packet packet,
                                            XMPPResourceConnection session,
                                            Queue<Packet> results,
                                            Map<String,Object> settings,
                                            RosterAbstract.PresenceType pres_type)
                                     throws NotAuthorizedException,
                                            TigaseDBException,
                                            NoConnectionIdException

      Method is responsible for processing incoming subscription request (i.e. in the receivers session manager).

      If the contact is already subscribed the an auto-reply with type='subscribded' is sent, otherwise contact is added to the roster (if it's missing/there is no current subscription), sets the subscription type to `PresenceType.in_subscribe` and subsequently broadcast presence update to all connected resources.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processInSubscribed

          protected void processInSubscribed(Packet packet,
                                             XMPPResourceConnection session,
                                             Queue<Packet> results,
                                             Map<String,Object> settings,
                                             RosterAbstract.PresenceType pres_type)
                                      throws NotAuthorizedException,
                                             TigaseDBException,
                                             NoConnectionIdException

      Method is responsible for processing incoming subscribed presence (i.e. in the receivers session manager).

      Contact is added to the roster (if it's missing/there is no current subscription), sets the subscription type to `PresenceType.in_subscribed` and subsequently, if subscription has changed,forwards the presence to user resource connection as well as broadcast presence update to all connected resources.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processInUnsubscribe

          protected void processInUnsubscribe(Packet packet,
                                              XMPPResourceConnection session,
                                              Queue<Packet> results,
                                              Map<String,Object> settings,
                                              RosterAbstract.PresenceType pres_type)
                                       throws NotAuthorizedException,
                                              TigaseDBException,
                                              NoConnectionIdException

      Method is responsible for processing incoming unsubscribe presence (i.e. in the receivers session manager).

      First method performs update of subscription of the given contact and subsequently the request is forwarded to the client to make sure it says in synch with the server (in case there was actual change in subscription). Lastly a roster push is generated to all connected resources to update them with current state of the roster and items subscriptions.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processInUnsubscribed

          protected void processInUnsubscribed(Packet packet,
                                               XMPPResourceConnection session,
                                               Queue<Packet> results,
                                               Map<String,Object> settings,
                                               RosterAbstract.PresenceType pres_type)
                                        throws NotAuthorizedException,
                                               TigaseDBException,
                                               NoConnectionIdException

      Method is responsible for processing incoming unsubscribed presence (i.e. in the receivers session manager).

      First method checks for the current subscription of the contact and if this verifies performs subsequent actions such as forwarding presence to the user connection to make sure it says in synch with the server, updates contact subscription with `PresenceType.in_unsubscribed` and in case that there was a change in user subscription send out a roster push to all connected resources to update them with current state of the roster and items subscriptions.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processOutInitial

          protected void processOutInitial(Packet packet,
                                           XMPPResourceConnection session,
                                           Queue<Packet> results,
                                           Map<String,Object> settings,
                                           RosterAbstract.PresenceType type)
                                    throws NotAuthorizedException,
                                           TigaseDBException

      Method is responsible for processing outgoing initial presence (i.e. in the sender session manager).

      Process packet accordingly whether it's a direct presence (forward it, add to proper collection of JIDs to which a direct presence has been sent) or regular presence. THe latter causes properly address the packet, store presence within session data for subsequent use, and for the first availability presence (in case there is no prior presence stored in user session data) server sends probes to all contacts and pushes out all pending subscription request or (if there i already presence stored in session data) broadcast presence update to contacts.

      If there is a JID forwarding set up, presence is also forwarded to configured JID.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `type` - specifies type of the presence.
      Throws:
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processOutSubscribe

          protected void processOutSubscribe(Packet packet,
                                             XMPPResourceConnection session,
                                             Queue<Packet> results,
                                             Map<String,Object> settings,
                                             RosterAbstract.PresenceType pres_type)
                                      throws NotAuthorizedException,
                                             TigaseDBException,
                                             NoConnectionIdException

      Method is responsible for processing outgoing subscribe and unsubscribe presence (i.e. in the sender session manager).

      Presence packet is forwarded to the destination with the JID stripped from the resource.

      In case of `PresenceType.out_subscribe` packet type contact is added to the roster (in case it was missing), a subscription state is being updated and, in case there was a change, a roster push is being sent to all user resources.

      In case of `PresenceType.out_unsubscribe` method updates contact subscription (and generates roster push if there was a change) and if the resulting contact subscription is NONE then contact is removed from the roster.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### processOutSubscribed

          protected void processOutSubscribed(Packet packet,
                                              XMPPResourceConnection session,
                                              Queue<Packet> results,
                                              Map<String,Object> settings,
                                              RosterAbstract.PresenceType pres_type)
                                       throws NotAuthorizedException,
                                              TigaseDBException,
                                              NoConnectionIdException

      Method is responsible for processing outgoing subscribed and unsubscribed presence (i.e. in the sender session manager).

      Presence packet is forwarded to the destination with the JID stripped from the resource, a subscription state is being updated and, in case there was a change, a roster push is being sent to all user resources. Also, in case of presence type out_subscribed server send current presence to the user from each of the contact's available resources. For the presence type out_unsubscribed an unavailable presence is sent.

      Parameters:
        `packet` - packet is which being processed.
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
        `settings` - this map keeps plugin specific settings loaded from the Tigase server configuration.
        `pres_type` - specifies type of the presence.
      Throws:
        `NoConnectionIdException`
        `NotAuthorizedException`
        `TigaseDBException`

    - #### sendRosterOfflinePresence

          protected void sendRosterOfflinePresence(XMPPResourceConnection session,
                                                   Queue<Packet> results)
                                            throws NotAuthorizedException,
                                                   TigaseDBException,
                                                   NoConnectionIdException

      Method sends server generated presence unavailable for all buddies from the roster with a custom status message.
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
      Throws:
        `TigaseDBException`
        `NotAuthorizedException`
        `NoConnectionIdException`

    - #### updateOfflineChange

          protected static void updateOfflineChange(XMPPResourceConnection session,
                                                    Queue<Packet> results)
                                             throws NotAuthorizedException

      `updateOfflineChange` method broadcast off-line presence to all other user active resources.
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `results` - this a collection with packets which have been generated as input packet processing results.
      Throws:
        `NotAuthorizedException` - if an error occurs

    - #### updateResourcesAvailable

          protected static void updateResourcesAvailable(XMPPResourceConnection session,
                                                         StanzaType type,
                                                         Packet packet)

      Method updates resources information upon receiving initial availability presence (type available or missing type)
      Parameters:
        `session` - user session which keeps all the user session data and also gives an access to the user's repository data.
        `type` - specifies type of the stanza.
        `packet` - packet is which being processed.

    - #### getRosterUtil

          protected static RosterAbstract getRosterUtil()

      Returns shared instance of class implementing `RosterAbstract` - either default one (`RosterFlat`) or the one configured with "roster-implementation" property.
      Returns:
        shared instance of class implementing `RosterAbstract`

Copyright © 2016 "Tigase, Inc.". All rights reserved.