<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Best Practices for Roster and Subscription Management</title>
  <abstract>This document specifies best practices for roster and subscription management in Jabber/XMPP clients.</abstract>
  &LEGALNOTICE;
  <number>0162</number>
  <status>Deferred</status>
  <type>Informational</type>
  <dependencies>None</dependencies>
  <supersedes>None</supersedes>
  <supersededby>None</supersededby>
  <sig>Standards</sig>
  <author>
    <firstname>Lucas</firstname>
    <surname>Nussbaum</surname>
    <email>lucas@lucas-nussbaum.net</email>
    <jid>lucas@nussbaum.fr</jid>
  </author>
  <shortname>N/A</shortname>
  <revision>
    <version>0.2</version>
    <date>2005-12-06</date>
    <initials>lnu</initials>
    <remark>Added a note about the name of the Hidden group. Clarified which items should be displayed.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2005-10-19</date>
    <initials>lnu</initials>
    <remark>Initial version.</remark>
  </revision>
  <revision>
    <version>0.0.3</version>
    <date>2005-10-18</date>
    <initials>lnu</initials>
    <remark>Added a remark about "Remove" vs "Block" in other IM systems.</remark>
  </revision>
  <revision>
    <version>0.0.2</version>
    <date>2005-10-07</date>
    <initials>lnu</initials>
    <remark>Integrated some feedback from Standards list discussion.</remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2005-10-04</date>
    <initials>lnu</initials>
    <remark>First draft.</remark>
  </revision>
</header>

<section1 topic='Introduction' anchor='intro'>
  <section2 topic='Motivation' anchor='intro-motive'>

    <p>&rfc3921; explains how subscriptions and rosters integrate. However,
    several points are left to the client author's discretion, and this can lead
    to some confusion among client developers. This document specifies best practices 
    that enable all Jabber clients to manage subscriptions and roster in a coherent 
    way, thus making sure that such clients will not surprise end users with 
    unexpected behavior.</p>

  </section2>

  <section2 topic='Overview of subscription states' anchor='intro-oversub'>

    <p>As defined in RFC 3921 (sections 6, 7, 8), a roster item can have one
    of the following subscription states:</p>

    <ul>

      <li><em>subscription='none'</em>: you aren't interested in the item's
      presence, and neither is the item interested in yours.</li>
      
      <li><em>subscription='from'</em>: the item is interested in your
    presence information, but you don't care about the contact. (You must
    be somebody important! ;)</li>

      <li><em>subscription='to'</em>: You are interested in the item's
    presence information, but the contact is not interested in
    yours.</li>
      
      <li><em>subscription='both'</em>: You and the contact are interested in each other's presence information.</li>

    </ul>

   <p>Additionally, if <em>subscription='from'</em> or
   <em>subscription='none'</em>, you can have <em>ask='suscribe'</em>, which
   means you sent a subscription request to the item but haven't received an
   answer yet.</p>

  </section2>

</section1>

<section1 topic='Removal of Contacts' anchor='removal'>
  <p>It is necessary to distinguish two things:</p>
  <ul>
  <li>Removal from the user's roster (does the user's roster include an entry
  for this JID?) ;</li>
  <li>Removal of presence subscription (cancellation of subscription).</li>
  </ul>
  <p>Three problems have to be taken into consideration here:</p>
  <ul>

  <li>Removing an item from your roster (i.e., performing a roster set with <em>subscription='remove'</em>) cancels all subscriptions (both from
  the item and to the item).</li>

  <li>The fact that a user is no longer interested in the contact's
  presence doesn't mean that the contact is no longer interested in the
  user's presence.</li>

  <li>This is complex, and should be presented in a simple way to the
  user.</li>

  </ul>

  <p>Therefore, the following behavior is RECOMMENDED for Jabber clients:</p>

  <ol>
    <li><p>When the user asks for the removal of an item with
  <em>subscription='both'</em>, the Jabber client SHOULD ask the user whether
  he wants to revoke the contact's authorization to see the user's presence
  too. This action SHOULD be called "Remove" since this is the convention used
  by other IM systems.</p></li>
    <li>
      <p>The Jabber client SHOULD NOT remove the contact from the roster. There
  are two exceptions:</p>
      <ol style='list-style-type: lower-alpha'>
        <li><p>The Jabber client MAY remove the contact from the roster if the user
  explicitely asked (so the user has to be informed he might remove both
  presence subscriptions).</p></li>
        <li><p>The jabber client MAY transparently remove the contact from the roster if
  the user asked to, and if <em>subscription='none'</em> or
  <em>subscription='to'</em>.</p></li>
      </ol>
    </li>
  </ol>
  
  <p>In addition to the "Remove" action described above, the client MAY
  provide a way to revoke the contact's subscription to the user's presence.
  This action, if provided, SHOULD be called "Block" since this is the
  convention used by other IM networks.</p>

</section1>
<section1 topic='Display of Contacts in the Roster' anchor='contacts'>

  <p>Defining a sensible roster policy is difficult, because many users have different, special needs. We have to ensure that:</p>
  <ul>
  <li>Most contacts that everybody wants to hide are hidden.</li>
  <li>No contact that someone wants to see is hidden.</li>
  </ul>

  <p>The user's roster contains both contacts of interest for the user
  (contacts with <em>subscription='both'</em> or <em>subscription='to'</em>) and contacts which
  are only interested in receiving the user's presence information. Also, the
  user might be interested in having some contacts even with
  <em>subscription='none'</em>, because he often send messages to them but isn't
  interested in their presence.</p>


  <p>Therefore, the following types of contacts SHOULD be displayed by clients:</p>
  <ul>
  <li>items with <em>subscription='both'</em> or <em>subscription='to'</em> ;</li>
  <li>items with <em>subscription='none'</em> or <em>subscription='from'</em> and <em>ask='subscribe'</em>. It is ((subscription='none' or subscription='from') and ask='subscribe') ;</li>
  <li>items with <em>subscription='none'</em> or <em>subscription='from'</em> which have a 'name' attribute or a 'group' child set. It is ((subscription='none' or subscription='from') and (name attribute or group child)).</li>
  </ul>

  <p>The client MAY display contacts with subscription='from' which don't match
  one of the above cases in an additional 'Observers' group. If no 'Observers' group is
  used, the client SHOULD NOT display contacts which don't match one of the
  above rules.</p>

  <p>Some users give nicknames to contacts they do not want to see, to be able to remember who they are when cleaning the roster. An additional 'Hidden' group MAY be used to handle such contacts. The client SHOULD NOT display contacts if one of their groups is the 'Hidden' group. (This mean that if contact 'C' is in groups 'G' and 'Hidden', 'C' should never be displayed, even in group 'G'.)</p>

  <section2 topic='Name of the Hidden group' anchor='hiddenname'>

  <p>The name of the 'Hidden' group can be managed in two different ways :</p>
  <ul>
  <li>It could always be named 'Hidden' but be displayed translated by the client ;</li>
  <li>It could be named as the user wants. Its name could then be stored using jabber:iq:private, like the delimiter for nested groups in &xep0083;.</li>
  </ul>
  <p>This is left as an open issue since no clients (to the author's knowledge) implement this 'Hidden' group. But the preference should go to the first solution, which avoids relying on &xep0049;.</p>

</section2>
</section1>
</xep>