<abstract>This document defines an XMPP protocol extension to indicate the presence priority of XMPP resources for applications other than messaging.</abstract>
<remark><p>Added support for RAP requests via IQ.</p></remark>
</revision>
<revision>
<version>0.0.4</version>
<date>2005-10-27</date>
<initials>psa/jjh</initials>
<remark><p>Defined registry of application types; clarified business rules; corrected schema.</p></remark>
</revision>
<revision>
<version>0.0.3</version>
<date>2005-10-24</date>
<initials>psa/jjh</initials>
<remark><p>Broadened previous resource flagging proposal to include priority for applications other than messaging.</p></remark>
</revision>
<revision>
<version>0.0.2</version>
<date>2005-09-26</date>
<initials>psa/jjh</initials>
<remark><p>Added more business rules and examples; defined service discovery guidelines.</p></remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2005-09-23</date>
<initials>psa/jjh</initials>
<remark><p>First draft.</p></remark>
</revision>
</header>
<section1topic='Introduction'anchor='intro'>
<p>Within the Extensible Messaging and Presence Protocol (XMPP; see &rfc3920;), presence indicates availability for communication -- specifically, communication via XMPP messaging (usually in the form of "instant messaging" or IM as described in &rfc3921;). However, a wide variety of entities might provide XMPP presence, including entities that are not primarily focused on IM (e.g., phones) or even entities that do not support XMPP messaging at all.</p>
<p>Consider a scenario in which a contact wants to initiate a voice chat (e.g., via &xep0166;) with a user who has the following three XMPP resources:</p>
<p>If the contact chooses the resource with which it initiates a voice chat based on the user's default XMPP presence priority (i.e., priority for XMPP messaging), the resulting behavior could be misleading (i.e., initiating the voice chat with the "desktop" resource rather than the "mobile" resource).</p>
<p>What is needed is a way for the user's clients to indicate that the application priority for the three resources is different from the standard XMPP messaging priority. This document defines such a mechanism via an optional XMPP presence extension.</p>
<p>In addition, this document also defines a way for an XMPP server to flag which resource it considers to be primary for any given application type, if it has information -- such as communication preferences -- that can help determine the primary resource.</p>
<p>Consider the three resources ("desktop", "pda", and "mobile") mentioned above. The presence stanzas received by a contact for those three resources would be as follows:</p>
<examplecaption='Contact receives presence from user'><![CDATA[
<p>(Note: This protocol uses a 'num' attribute rather than a 'priority' attribute to reduce confusion with XMPP presence and also to save some bytes.)</p>
<p>The following business rules apply to resource application presence provided by the client:</p>
<olstart='1'>
<li><p>A client SHOULD NOT specify resource application presence if the priority for that application is not different from the resource's XMPP messaging priority.</p></li>
<li><p>A client MUST NOT generate a <rap/> element that has an 'app' attribute whose value is "messaging" or that has no 'app' attribute (since the default 'app' is "messaging").</p></li>
</ol>
</section1>
<section1topic='Flagging the Primary Resource for a Given Application Type'anchor='primary'>
<p>The user's server may have special information that enables it to flag a resource as primary for a given application type. For instance, the server may include a communication policy service that enables the user to define (outside the context of any presence priorities) that she would prefer to be called at her "desktop" resource only between the hours of 9:00 AM and 5:00 PM local time, prefer to be called on her mobile at all other times, and so on.</p>
<p>To flag the primary resource related to a specific application type, the server shall add a <primary/> child to the relevant RAP element. Here is an example:</p>
<p>The following business rules apply to resource flagging by the server:</p>
<olstart='1'>
<li><p>A server MAY add the primary resource flag to the presence broadcasts generated by the resource it determines is "most available" for a given application type.</p></li>
<li><p>Because the default 'app' is "im", to flag the primary resource for XMPP messaging the server SHOULD NOT include an 'app' attribute, SHOULD NOT include a 'num' attribute, and MUST include a <primary/> child.</p></li>
<li><p>An available resource that has specified a negative priority for an application type MUST NOT be flagged as the primary resource for that application type.</p></li>
<li><p>A client SHOULD NOT include the primary resource flag in presence stanzas that it generates; however, if a client includes the primary resource flag in a presence stanza, the server SHOULD remove or overwrite the flag.</p></li>
<li><p>In response to a presence probe, a server SHOULD send presence from the primary resource first (this enables the receiving client to skip any local most-available algorithms it might implement).</p></li>
<li><p>If the primary resource changes for a given application type, a server MUST push presence (including the primary resource flag) for the new primary resource. If the change in primary resource occurs because of a presence broadcast from the current primary resource, the server MUST push presence from the current primary resource (without the primary resource flag) before pushing presence from the new primary resource (including the primary resource flag).</p></li>
</ol>
</section1>
<section1topic='Requesting RAP Data Via IQ'anchor='raprequest'>
<p>In the interest of saving bandwidth, a server MAY choose to strip all RAP data out of presence stanzas and instead provide RAP data only on request via IQ interactions.
<li><p>Contact's client sends &xep0030; information request to user's client or receives &xep0115; data from user's client, and thereby discovers that user's client supports the 'http://jabber.org/protocol/rap' namespace.</p></li>
<li><p>User's client publishes RAP extensions but user's server strips them out in presence broadcasts.</p></li>
<li><p>Contact decides to initiate a non-IM interaction with user.</p></li>
<li><p>Contact's client notices the lack of RAP data from user (despite discovered support) and sends disco#info request to user's server, which signals that it supports the 'http://jabber.org/protocol/raprequest' namespace.</p></li>
<li><p>Contact's client sends RAP request to user's bare JID (&BAREJID;).</p></li>
<li><p>If contact is authorized to view user's presence data, user's server returns the latest RAP data for all of the user's resources. (Note: See the <linkurl='#security'>Security Considerations</link> section of this document for an important proviso regarding access to RAP data.)</p></li>
</ol>
<p>An example protocol flow for the last two steps is as follows...</p>
<p>First, the contact's client requests the user's RAP data by sending a request to the user's bare JID:</p>
<examplecaption='Contact requests RAP data from user's server'><![CDATA[
<p>On behalf of the user, the user's server then returns the full &PRESENCE; stanzas (containing RAP data) for each of the user's connected clients:</p>
<examplecaption='User's server returns RAP data'><![CDATA[
<p>Note: The XML data of the server's response to a RAP request may seem to be potentially confusing, but it is fully consistent with &w3xmlnamespaces; as well as the schemas for the 'jabber:client' and 'http://jabber.org/protocol/raprequest' namespaces.</p>
<p>If the queried entity supports resource application presence as well as RAP requests (see the <linkurl='raprequest'>Requesting RAP Data Via IQ</link> section of this document), it MUST return features of "http://jabber.org/protocol/rap" and "http://jabber.org/protocol/raprequest":</p>
<examplecaption='Server communicates protocol support for RAP as well as RAP Request'><![CDATA[
<p>Neither client publishing of resource application priority nor server flagging of the primary resource introduces any known security vulnerabilities or compromises of user privacy.</p>
<p>If a server supports RAP requests, it MUST carefully control access to RAP data in order to guard against presence leaks and directory harvest attacks. Specifically, if the requesting entity is not authorized (e.g., a contact with a presence subscription of "both" or "from" as described in <cite>RFC 3921</cite>) or is not explicitly trusted (e.g., a server in a trusted network), the server MUST return a &forbidden; error in response to RAP requests.</p>
<p>The XMPP Registrar shall maintain a registry of application types. Although strictly speaking this should not be necessary, it is desirable to maintain a list of "short names" for various application types rather than using long XML namespaces, especially in presence broadcasts. For example, a short name of "jingle-audio" is only 12 characters long, whereas the full XML namespace "http://jabber.org/protocol/jingle/description/audio" is 48 characters long. The difference can be quite significant when many presence stanzas are sent.</p>