<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//OASIS/DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<article id="index">
 <articleinfo>
  <title>Status Notifier Specification</title>
 </articleinfo>

 <sect1 id="introduction">
  <title>Introduction</title>
  <para>
   This specification defines the management of visual items, usually icons used for reporting the status of an application to the user or provide a quick access to common actions performed by that application. It is intended to be complementary but not directly related with the Freedesktop's Desktop Notifications specification and is aimed as a replacement to the Freedesktop System tray specification.
  </para>
  <para>
   This specification does not define what the aspect of the Notification Items will be, this is strictly implementation specific.
  </para>
  <para>
   Example use cases will include:
  </para>
  <itemizedlist>
   <listitem>
    <para>Mixer volume control.</para>
   </listitem>
   <listitem>
    <para>Battery indicator.</para>
   </listitem>
   <listitem>
    <para>Instant messenger on-line status.</para>
   </listitem>
   <listitem>
    <para>Generic application information and actions, like a media player controls.</para>
   </listitem>
  </itemizedlist>
 </sect1>

 <sect1 id="basic-design">
  <title>Basic Design</title>
  <para>
    The Status Notifier Item system relies on inter-process communication via D-BUS and is composed by three parts:
  </para>
  <itemizedlist>
   <listitem>
    <para>
     StatusNotifierItem: each application that wants to utilize the system registers its own StatusNotifierItem to the session bus. Properties, methods and signals that must be provided by all StatusNotifierItem instances are described in <xref  linkend="StatusNotifierItem"/>.
    </para>
   </listitem>
   <listitem>
    <para>
     StatusNotifierWatcher: service used to keep track of every active instance of StatusNotifierItem, used by StatusNotifierHost to get the list of all items. It also notifies it when items are added and removed. The detailed specification of StatusNotifierWatcher is described in <xref  linkend="StatusNotifierWatcher"/>.
    </para>
   </listitem>
   <listitem>
    <para>
     StatusNotifierHost: an application that wants to provide a visualization of the existing StatusNotifierItem instances must register a StatusNotifierHost in the session bus. The detailed specification of StatusNotifierHost is described in <xref  linkend="StatusNotifierHost"/>.
    </para>
   </listitem>
  </itemizedlist>
 </sect1>

 <sect1 id="StatusNotifierItem">
  <title>StatusNotifierItem</title>
  <para>
   Each application can register an arbitrary number of Status Notifier Items by registering on the session bus the service <literal>org.freedesktop.StatusNotifierItem-PID-ID</literal>, where PID is the process id of the application and ID is an arbitrary numeric unique identifier between different instances registered by the same application.
  </para>
  <para>
   As soon as a new instance of a StatusNotifierItem is created, the application must register the unique instance name to the StatusNotifierWatcher as described in <xref  linkend="StatusNotifierWatcher"/>
  </para>
  <para>
   Each instance of StatusNotifierItem must provide an object called <literal>StatusNotifierItem</literal> with the following properties, methods and signals described in the following sections.
  </para>
  <sect2 id="StatusNotifierItemProperties">
   <title>Properties</title>

   <sect3 id="category">
    <title><literal>org.freedesktop.StatusNotifierItem.Category</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.Category</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>Describes the category of this item.</para>
    <para>The allowed values for the Category property are:</para>
    <itemizedlist>
     <listitem>
      <para><literal>ApplicationStatus</literal>: The item describes the status of a generic application, for instance the current state of a media player.</para>
     </listitem>
     <listitem>
      <para><literal>Communications</literal>: The item describes the status of communication oriented applications, like an instant messenger or an email client.</para>
     </listitem>
     <listitem>
      <para><literal>SystemServices</literal>: The item describes services of the system not seen as a stand alone application by the user, such as an indicator for the activity of a disk indexing service.</para>
     </listitem>
     <listitem>
      <para><literal>Hardware</literal>: The item describes the state and control of a particular hardware, such as an indicator of the battery charge or sound card volume control.</para>
     </listitem>
    </itemizedlist>
   </sect3>

   <sect3 id="id">
    <title><literal>org.freedesktop.StatusNotifierItem.Id</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.Id</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>It's a name that should be unique for this application and consistent between sessions, such as the application name itself.</para>
   </sect3>

   <sect3 id="title">
    <title><literal>org.freedesktop.StatusNotifierItem.Title</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.Title</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>It's a name that describes the application, it can be more descriptive than Id.</para>
   </sect3>

  <sect3 id="status">
    <title><literal>org.freedesktop.StatusNotifierItem.Status</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.Status</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>Describes the status of this item or of the associated application.</para>
    <para>The allowed values for the Status property are:</para>
    <itemizedlist>
     <listitem>
      <para><literal>Passive</literal>: The item doesn't convey important information to the user, it can be considered an <quote>idle</quote> status and is likely that visualizations will chose to hide it.</para>
     </listitem>
     <listitem>
      <para><literal>Active</literal>: The item is active, is more important that the item will be shown in some way to the user.</para>
     </listitem>
     <listitem>
      <para><literal>NeedsAttention</literal>: The item carries really important information for the user, such as battery charge running out and is wants to incentive the direct user intervention. Visualizations should emphasize in some way the items with NeedsAttention status.</para>
     </listitem>
    </itemizedlist>
   </sect3>

   <sect3 id="WindowId">
    <title><literal>org.freedesktop.StatusNotifierItem.WindowId</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>UINT32
       <function>org.freedesktop.StatusNotifierItem.WindowId</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>It's the windowing-system dependent identifier for a window, the application can chose one of its windows to be available trough this property or just set 0 if it's not interested.</para>
   </sect3>

   <sect3 id="IconName">
    <title><literal>org.freedesktop.StatusNotifierItem.IconName</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.IconName</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>The StatusNotifierItem can carry an icon that can be used by the visualization to identify the item.</para>
    <para>An icon can either be identified by its Freedesktop-compliant icon name, carried by this property of by the icon data itself, carried by the property <literal>IconPixmap</literal>. Visualizations are encouraged to prefer icon names over icon pixmaps if both are available (FIXME: still not very defined: could e the pixmap used as fallback if an icon name is not found?)</para>
   </sect3>

   <sect3 id="IconPixmap">
    <title><literal>org.freedesktop.StatusNotifierItem.IconPixmap</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>ARRAY(INT, INT, ARRAY BYTE)
       <function>org.freedesktop.StatusNotifierItem.IconPixmap</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>Carries an ARGB32 binary representation of the icon, the format of icon data used in this specification is described in Section <xref linkend="icons"/></para>
   </sect3>

   <sect3 id="OverlayIconName">
    <title><literal>org.freedesktop.StatusNotifierItem.OverlayIconName</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.OverlayIconName</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>The Freedesktop-compliant name of an icon. This can be used by the visualization to indicate extra state information, for instance as an overlay for the main icon.</para>
   </sect3>

   <sect3 id="OverlayIconPixmap">
    <title><literal>org.freedesktop.StatusNotifierItem.OverlayIconPixmap</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>ARRAY(INT, INT, ARRAY BYTE)
       <function>org.freedesktop.StatusNotifierItem.OverlayIconPixmap</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>ARGB32 binary representation of the overlay icon described in the previous paragraph.</para>
   </sect3>

   <sect3 id="AttentionIconName">
    <title><literal>org.freedesktop.StatusNotifierItem.AttentionIconName</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.AttentionIconName</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>The Freedesktop-compliant name of an icon. this can be used by the visualization to indicate that the item is in <literal>RequestingAttention</literal> state.</para>
   </sect3>

   <sect3 id="AttentionIconPixmap">
    <title><literal>org.freedesktop.StatusNotifierItem.AttentionIconPixmap</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>ARRAY(INT, INT, ARRAY BYTE)
       <function>org.freedesktop.StatusNotifierItem.AttentionIconPixmap</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>ARGB32 binary representation of the requesting attention icon describe in the previous paragraph.</para>
   </sect3>

   <sect3 id="AttentionMovieName">
    <title><literal>org.freedesktop.StatusNotifierItem.AttentionMovieName</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>STRING
       <function>org.freedesktop.StatusNotifierItem.AttentionMovieName</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>An item can also specify an animation associated to the <literal>RequestingAttention</literal> state. This should be either a Freedesktop-compliant icon name or a full path. The visualization can chose between the movie or AttentionIconPixmap (or using neither of those) at its discretion.</para>
   </sect3>

  <sect3 id="ToolTip">
    <title><literal>org.freedesktop.StatusNotifierItem.ToolTip</literal></title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>(STRING, ARRAY(INT, INT, ARRAY BYTE), STRING, STRING)
       <function>org.freedesktop.StatusNotifierItem.ToolTip</function>
      </funcdef>
      <paramdef/>
     </funcprototype>
    </funcsynopsis>
    <para>Data structure that describes extra information associated to this item, that can be visualized for instance by a tooltip (or by any other mean the visualization consider appropriate. Components are:</para>
    <itemizedlist>
    <listitem>
        <para>STRING: Freedesktop-compliant name for an icon.</para>
    </listitem>
    <listitem>
        <para>ARRAY(INT, INT, ARRAY BYTE): icon data</para>
    </listitem>
    <listitem>
        <para>STRING: title for this tooltip</para>
    </listitem>
    <listitem>
        <para>STRING: descriptive text for this tooltip. It can contain also a subset of the HTML markup language, for a list of allowed tags see Section <xref linkend="markup"/>.</para>
    </listitem>
    </itemizedlist>
   </sect3>
  </sect2>

  <sect2 id="StatusNotifierItemMethods">
   <title>Methods</title>
   <sect3 id="ContextMenu">
    <title>ContextMenu</title>
    <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.ContextMenu</function>
        </funcdef>
        <paramdef>INT <parameter>x</parameter></paramdef>
        <paramdef>INT <parameter>y</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
    <para>Asks the status notifier item to show a context menu, this is typically a consequence of user input, such as mouse right click over the graphical representation of the item.</para>
    <para>the x and y parameters are in screen coordinates and is to be considered an hint to the item about where to show the context menu.</para>
   </sect3>

   <sect3 id="Activate">
    <title>Activate</title>
    <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.Activate</function>
        </funcdef>
        <paramdef>INT <parameter>x</parameter></paramdef>
        <paramdef>INT <parameter>y</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
    <para>Asks the status notifier item for activation, this is typically a consequence of user input, such as mouse left click over the graphical representation of the item. The application will perform any task is considered appropriate as an activation request.</para>
    <para>the x and y parameters are in screen coordinates and is to be considered an hint to the item where to show eventual windows (if any).</para>
   </sect3>

   <sect3 id="SecondaryActivate">
    <title>SecondaryActivate</title>
    <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.SecondaryActivate</function>
        </funcdef>
        <paramdef>INT <parameter>x</parameter></paramdef>
        <paramdef>INT <parameter>y</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
    <para>Is to be considered a secondary and less important form of activation compared to Activate. This is typically a consequence of user input, such as mouse middle click over the graphical representation of the item. The application will perform any task is considered appropriate as an activation request.</para>
    <para>the x and y parameters are in screen coordinates and is to be considered an hint to the item where to show eventual windows (if any).</para>
   </sect3>

   <sect3 id="Scroll">
    <title>Scroll</title>
    <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.Scroll</function>
        </funcdef>
        <paramdef>INT <parameter>delta</parameter></paramdef>
        <paramdef>STRING <parameter>orientation</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
    <para>The user asked for a scroll action. This is caused from input such as mouse wheel over the graphical representation of the item.</para>
    <para>The <literal>delta</literal> parameter represent the amount of scroll, the <literal>orientation</literal> parameter represent the horizontal or vertical orientation of the scroll request and its legal values are <literal>horizontal</literal> and <literal>vertical</literal>.</para>
   </sect3>
  </sect2>


  <sect2 id="StatusNotifierItemSignals">
   <title>Signals</title>
   <sect3 id="NewTitle">
     <title>NewTitle</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.NewTitle</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>The item has a new title: the graphical representation should read it again immediately.</para>
   </sect3>

   <sect3 id="NewIcon">
     <title>NewIcon</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.NewIcon</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>The item has a new icon: the graphical representation should read it again immediately.</para>
   </sect3>

   <sect3 id="NewAttentionIcon">
     <title>NewAttentionIcon</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.NewAttentionIcon</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>The item has a new attention icon: the graphical representation should read it again immediately.</para>
   </sect3>

   <sect3 id="NewOverlayIcon">
     <title>NewOverlayIcon</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.NewOverlayIcon</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>The item has a new overlay icon: the graphical representation should read it again immediately.</para>
   </sect3>

   <sect3 id="NewToolTip">
     <title>NewToolTip</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.NewToolTip</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>The item has a new tooltip: the graphical representation should read it again immediately.</para>
   </sect3>

   <sect3 id="NewStatus">
     <title>NewStatus</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierItem.NewStatus</function>
        </funcdef>
        <paramdef>STRING <parameter>status</parameter></paramdef>
      </funcprototype>
     </funcsynopsis>
     <para>The item has a new status, that is passed as an argument of the signal.</para>
   </sect3>
  </sect2>
 </sect1>


 <sect1 id="StatusNotifierWatcher">
  <title>StatusNotifierWatcher</title>
  <para>There will be a single <literal>org.freedesktop.StatusNotifierWatcher</literal> service instance registered on the session but at any given time. The <literal>StatusNotifierWatcher</literal> service is used to keep track of <literal>StatusNotifierItem</literal> instances, enumerate them and notify when new ones are registered or old ones are unregistered.</para>
  <para>It is also used to keep track of <literal>org.freedesktop.StatusNotifierHost</literal> instances, to have an easy way to know if there is at least one service registered as the visualization host for the status notifier items.</para>
  <sect2>
    <title>Methods</title>
    <sect3 id="RegisterStatusNotifierItem">
     <title>RegisterStatusNotifierItem</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierWatcher.RegisterStatusNotifierItem</function>
        </funcdef>
        <paramdef>STRING <parameter>service</parameter></paramdef>
      </funcprototype>
     </funcsynopsis>
     <para>Register a <literal>StatusNotifierItem</literal> into the <literal>StatusNotifierWatcher</literal>, in the form of its full name on the session bus, for instance <literal>org.freedesktop.StatusNotifierItem-4077-1</literal>. A StatusNotifierItem instance must be registered to the watcher in order to be noticed from both the watcher and the <literal>StatusNotifierHost</literal> instances. If the registered StatusNotifierItem goes away from the session bus, the StatusNotifierWatcher should automatically notice it and remove it from the list of registered services.</para>
   </sect3>

   <sect3 id="RegisterStatusNotifierHost">
     <title>RegisterStatusNotifierHost</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>VOID
          <function>org.freedesktop.StatusNotifierWatcher.RegisterStatusNotifierHost</function>
        </funcdef>
        <paramdef>STRING <parameter>service</parameter></paramdef>
      </funcprototype>
     </funcsynopsis>
     <para>Register a <literal>StatusNotifierHost</literal> into the <literal>StatusNotifierWatcher</literal>, in the form of its full name on the session bus, for instance <literal>org.freedesktop.StatusNotifierHost-4005</literal>. Every NotficationHost instance that intends to display StatusNotifierItem representations should register to StatusNotifierWatcher with this method. The StatusNotifierWatcher should automatically notice if an instance of StatusNotifierHost goes away.</para>
   </sect3>
 </sect2>

 <sect2>
   <title>Properties</title>
   <sect3 id="RegisteredStatusNotifierItems">
     <title>RegisteredStatusNotifierItems</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>ARRAY(STRING)
          <function>org.freedesktop.StatusNotifierWatcher.RegisteredStatusNotifierItems</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>List containing all the registered instances of <literal>StatusNotifierItem</literal>. All elements of the array should correspond to services actually running on the session bus at the moment of the method call.</para>
   </sect3>

   <sect3 id="IsStatusNotifierHostRegistered">
     <title>IsStatusNotifierHostRegistered</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>BOOL
          <function>org.freedesktop.StatusNotifierWatcher.IsStatusNotifierHostRegistered</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>True if at least one <literal>StatusNotifierHost</literal> has been registered with <xref  linkend="RegisterStatusNotifierHost"/> and is currently running. If no StatusNotifierHost are registered and running, all StatusNotifierItem instances should fall back using the Freedesktop System tray specification.</para>
   </sect3>

   <sect3 id="ProtocolVersion">
     <title>ProtocolVersion</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>INT
          <function>org.freedesktop.StatusNotifierWatcher.ProtocolVersion</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>The version of the protocol the <literal>StatusNotifierWatcher</literal> instance implements.</para>
   </sect3>
  </sect2>

  <sect2>
    <title>SIGNALS</title>
    <sect3 id="StatusNotifierItemRegistered">
     <title>StatusNotifierItemRegistered</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>BOOL
          <function>org.freedesktop.StatusNotifierWatcher.StatusNotifierItemRegistered</function>
        </funcdef>
        <paramdef>STRING <parameter>service</parameter></paramdef>
      </funcprototype>
     </funcsynopsis>
     <para>A new <literal>StatusNotifierItem</literal> has been registered, the argument of the signal is the session bus name of the instance. StatusNotifierHost implementation should listen this signal to know when they should update their representation of the items.</para>
   </sect3>

    <sect3 id="StatusNotifierItemUnregistered">
     <title>StatusNotifierItemUnregistered</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>BOOL
          <function>org.freedesktop.StatusNotifierWatcher.StatusNotifierItemUnregistered</function>
        </funcdef>
        <paramdef>STRING <parameter>service</parameter></paramdef>
      </funcprototype>
     </funcsynopsis>
     <para>A <literal>StatusNotifierItem</literal> instance has disappeared from the bus, the argument of the signal is the session bus name of the instance. StatusNotifierHost implementation should listen this signal to know when they should update their representation of the items.</para>
   </sect3>

   <sect3 id="StatusNotifierHostRegistered">
     <title>StatusNotifierHostRegistered</title>
     <funcsynopsis>
      <funcprototype>
        <funcdef>BOOL
          <function>org.freedesktop.StatusNotifierWatcher.StatusNotifierHostRegistered</function>
        </funcdef>
        <paramdef/>
      </funcprototype>
     </funcsynopsis>
     <para>A new <literal>StatusNotifierHost</literal> has been registered, the StatusNotifierItem instances knows that they can use this protocol instead of the Freedesktop System tray protocol.</para>
   </sect3>
  </sect2>
 </sect1>

 <sect1 id="StatusNotifierHost">
  <title>StatusNotifierHost</title>
  <para><literal>StatusNotifierHost</literal> corresponds an object in an application that does the actual graphical representation of <literal>StatusNotifierItem</literal> instances.</para>
  <para>Instances of this service are registered on the Dbus session bus, under a name on the form <literal>org.freedesktop.StatusNotifierHost-id</literal> where <literal>id</literal> is an unique identifier, that keeps the names unique on the bus, such as the process-id of the application or another type of identifier if more that one StatusNotifierHost is registered by the same process.</para>
  <para><literal>StatusNotifierHost</literal> instances don't need any particular property, method or signal registered to the bus. What is important is the presence of the service on the bus, to inform <literal>StatusNotifierWatcher</literal> that a StatusNotifierItem representation is currently running on the system.</para>
 </sect1>

 <sect1 id="backwards-compatibility">
  <title>Backwards Compatibility</title>
  <para>
   Implementers of StatusNotifierItem should support the Freedesktop Systemtray specification too, and should use that instead of the Status notifier protocol in one of the following scenarios:
  </para>
  <itemizedlist>
   <listitem>
    <para>The service <literal>org.freedesktop.StatusNotifierWatcher</literal> is not registered on the session bus</para>
   </listitem>
   <listitem>
    <para>The service <literal>org.freedesktop.StatusNotifierWatcher</literal> is registered on the session bus, but the method <literal>org.freedesktop.StatusNotifierWatcher.IsStatusNotifierHostRegistered</literal> returns <literal>FALSE</literal>.</para>
   </listitem>
  </itemizedlist>
  <para>
   As soon as <literal>org.freedesktop.StatusNotifierWatcher</literal> appears on the session bus and <literal>org.freedesktop.StatusNotifierWatcher.IsStatusNotifierHostRegistered</literal> returns true the Freedesktop Systemtray item should be deleted and the StatusNotifierItem should be registered instead.
  </para>
  <para>
   In the same way a StatusNotifierItem should be registered when arrives the signal <literal>org.freedesktop.StatusNotifierWatcher.StatusNotifierHostRegistered</literal> and no StatusNotifierHost were registered before.
  </para>
 </sect1>

 <sect1 id="markup" xreflabel="Markup">
  <title>Markup</title>
  <para>
   The sub text of a tooltip may contain markup. The markup is XML-based, and consists
   of a small subset of XHTML.
  </para>
  <para>
   The following tags should be supported by the StatusNotifierHost visualization.
   Though it is optional, it is recommended. StatusNotifierHost that do
   not support these tags should filter them out.
  </para>
  <informaltable>
   <tgroup cols="2">
    <tbody valign="top">
     <row>
      <entry>
       <sgmltag class="starttag">b</sgmltag> ...
       <sgmltag class="endtag">b</sgmltag>
      </entry>
      <entry>Bold</entry>
     </row>
     <row>
      <entry>
       <sgmltag class="starttag">i</sgmltag> ...
       <sgmltag class="endtag">i</sgmltag>
      </entry>
      <entry>Italic</entry>
     </row>
     <row>
      <entry>
       <sgmltag class="starttag">u</sgmltag> ...
       <sgmltag class="endtag">u</sgmltag>
      </entry>
      <entry>Underline</entry>
     </row>
     <row>
      <entry>
       <sgmltag class="starttag">a href="..."</sgmltag> ...
       <sgmltag class="endtag">a</sgmltag>
      </entry>
      <entry>Hyperlink</entry>
     </row>
     <row>
      <entry>
       <sgmltag class="emptytag">img src="..." alt="..."</sgmltag>
      </entry>
      <entry>Image</entry>
      <paragraph>Images can be used with absolute pathnames as image source. The alt tab is mandatory.</paragraph>
     </row>
    </tbody>
   </tgroup>
  </informaltable>
  <para>
   A full-blown HTML implementation is not required of this spec, and
   notifications should never take advantage of tags that are not listed
   above. As tooltips are not a substitute for complex
   dialogs, advanced layout is not necessary, and may in fact limit the
   number of systems where this system can run on, due to memory
   usage and screen space. Such examples are PDAs, certain cell phones, and
   slow PCs or laptops with little memory.
  </para>
  <para>
   For the same reason, a full XML or XHTML implementation using XSLT or
   CSS stylesheets is not part of this specification. Information that
   must be presented in a more complex form should use an application-specific
   dialog, a web browser, or some other display mechanism.
  </para>
  <para>
   The tags specified above mark up the content in a way that allows them
   to be stripped out on some implementations without impacting the actual
   content.
  </para>
 </sect1>

 <sect1 id="icons" xreflabel="Icons">
  <title>Icons</title>
  <para>
   All the icons can be transferred over the bus by a particular serialization of their data, capabe of representing multiple resolutions of the same image or a brief aimation of images of the same size.
  </para>
  <para>
   Icons are transferred in an array of raw image data structures of signature
   a(iiay) whith each one describing the width, height, and image data respectively. The data is represented in ARGB32 format and is in the network byte order, to make easy the communication over the network between little and big endian machines.
  </para>
 </sect1>


 <sect1 id="scenario" xreflabel="Use case scenario">
  <title>Use case scenario</title>
  <para>
   Here we show in pseudocode a tipical usage scenario of the three components. In this examples a service is registered to DBus by registering a class with the registerToDBus() function call. the function pid() returns the process-id of the application and uniqueId() returns each an unique id in the application (it can just be a progressive integer). Those are used to generate an unique name on the session bus.
  </para>
  <para>
    The function getDBusConnection() returns an object with all of the methods, properties and signals of a service registered on the bus.
  </para>
  <sect2 id="StatusNotifierItemScenario">
    <title>StatusNotifierItem</title>
    <para>
      An application that wants to register a new StatusNotifierItem has to do the following steps (providing we have a class, here called StatusNotifierItem with methods to set its properties, any other programming paradigm can be used in implementations). The applicatin in this example is an hypothetical sound mixer application.
    </para>
    <programlisting>
      StatusNotifierItem statusNotifierItem = new StatusNotifierItem();
      String statusNotifierItemBusName = "org.freedesktop.StatusNotifierItem-"
                                       + pid() + "-" + uniqueId();
      registerToDBus(statusNotifierItemBusName);

      //setting the properties the StatusNotifierItem
      statusNotifierItem.setId("Mixer");
      //no signal emitted: Id is not supposed to change again

      statusNotifierItem.setTitle("Volume control");
      //at this point statusNotifierItem emitted the NewTitle signal

      statusNotifierItem.setCategory(Hardware);
      //no signal emitted: Category is not supposed to change

      statusNotifierItem.setStatus(Active);
      //statusNotifierItem emitted NewStatus signal

      //here we use just icon names and not icon pixmaps
      statusNotifierItem.setIconName("mixer");
      //NewIcon emitted

      statusNotifierItem.setTooltipIconName("mixer");
      statusNotifierItem.setTooltipTitle("Sound mixer");
      statusNotifierItem.setTooltipText("Control your soundcard volume");
      //NewToolTip emitted: implementations are encouraged to emit this signal
      //just one time after all changes are done

      StatusNotifierWatcherConnection watcher
              = getDBusConnection("org.freedesktop.StatusNotifierWatcher");

      watcher.RegisterService(statusNotifierItemBusName);
    </programlisting>

    <para>
      At this point the item should be visualized in any StatusNotifierHost that displays items of <literal>Hardware</literal> type.
    </para>
    <para>
      Each time a new property will be setted, the StatusNotifierItem implementation must emit the proper signal.
    </para>
  </sect2>
  <sect2 id="StatusNotifierItemWarcherScenario">
    <title>StatusNotifierWatcher</title>
    <para>
      The StatusNotifierWatcher has to emit the StatusNotifierItemRegistered signal every time somebdy calls RegisterService on it and emit ServiceUnRegistered when that service disappear on the session bus.
    </para>
    <para>
      The RegisateredServices method must return a list composed of only names that are actually registered on the session bus.
    </para>
    <para>
      When RegisterStatusNotifierHost is register, the StatusNotifierHostRegistered signal must be emitted. Below there is the pseudocode for the RegisterService method, here the m_services sontains a list of all the registered StatusNotifierItem instances.
    </para>
    <programlisting>
      void RegisterService(string serviceName)
      {
          //we try to connect to find out if the name is valid
          if (getDBusConnection(serviceName).isValid()) {
              m_services.append(serviceName);
              emit StatusNotifierItemRegistered(serviceName);
          }
      }
    </programlisting>
  </sect2>
  <sect2 id="StatusNotifierHostScenario">
    <title>StatusNotifierHost</title>
    <para>
      When a StatusNotifierHost instance starts it must register itself on StatusNotifierWatcher and then fetch from it the list of registered StatusNotifierItems and listen for new one registered or old ones going away.
    </para>
    <para>
      It should also keep in sync all properties like icons, states and tooltips.
    </para>
    <programlisting>
      String statusNotifierHostName = "org.freedesktop.StatusNotifierHost-"
                                       + pid() + "-" + uniqueId();
      registerToDBus(statusNotifierHostName);

      StatusNotifierWatcherConnection watcher
               = getDBusConnection("org.freedesktop.StatusNotifierWatcher");

      watcher.registerStatusNotifierHost(statusNotifierHostName);

      connect(watcher, SIGNAL(StatusNotifierItemRegistered()), this, SLOT(StatusNotifierItemRegistered()));
      connect(watcher, SIGNAL(StatusNotifierItemUnregistered()), this, SLOT(ServiceUnRegistered()));

      m_itemList = watcher.RegisteredStatusNotifierItems();

      foreach (string service, m_itemList) {
          StatusNotifierItemConnection item = getDBusConnection(service);
          //we will have a slot called when the asyncronous GetAll() is done
          //it will create or update the actual visual representation of the item
          item.GetAll();
      }
    </programlisting>
  </sect2>
 </sect1>
</article>

