<?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>Rayo Fax</title>
  <abstract>This specification defines an extension to the Rayo protocol (XEP-0327) to provide provision for sending and receiving faxcimilies via a call under the control of a Rayo client.</abstract>
  &LEGALNOTICE;
  <number>0342</number>
  <status>Experimental</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0327 Rayo</spec>
    <spec>XEP-0341 Rayo CPA</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  <author>
    <firstname>Ben</firstname>
    <surname>Langfeld</surname>
    <email>ben@langfeld.me</email>
    <jid>ben@langfeld.me</jid>
    <uri>http://langfeld.me</uri>
  </author>
  <revision>
    <version>0.2</version>
    <date>2014-03-13</date>
    <initials>bl</initials>
    <remark><p>Specify dependencies correctly; clearer wording on security considerations; proper linking.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2014-01-14</date>
    <initials>psa</initials>
    <remark><p>Initial published version approved by the XMPP Council.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2013-10-02</date>
    <initials>bl</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic='Introduction' anchor='intro'>
  <p>Rayo allows for the third-party control of media sessions such as telephone calls. A common requirement in telephony applications providing backward compatability with legacy systems is to support sending and receiving faxes. This specification extends the core Rayo specification, to describe a protocol for this use case.</p>
</section1>
<section1 topic='Session Flow' anchor='session'>
  <p>This section describes the form, function and order of Rayo stanzas sent across the wire, and the circumstances in which they apply and/or may arise.</p>

  <section2 topic='Receiving Faxes' anchor='session-receiving'>
    <p>A Rayo client may utilise <link url=''>Rayo CPA</link> to establish a fax CNG tone before initiating fax receipt using the receivefax component described below.</p>

    <p>The receivefax component accepts a fax from a caller, stores it, and makes it available to Rayo clients. The component is created using a <link url='#def-receivefax'>&lt;receivefax/&gt; command</link>.</p>

    <example caption='Client receives a fax'><![CDATA[
<iq from='juliet@capulet.lit/balcony'
  to='9f00061@call.shakespeare.lit'
  type='set'
  id='h7ed2'>
  <receivefax xmlns='urn:xmpp:rayo:fax:1'/>
</iq>
    ]]></example>

    <p>The server MUST validate that it has apropriate resources/mechanisms to receive the fax before acknowledging the component creation.</p>

    <section3 topic='Commands' anchor='session-receiving-commands'>
      <p>The receivefax component does not implement any intermediary commands.</p>
    </section3>

    <section3 topic='Events' anchor='session-receiving-events'>
      <p>The receivefax component does not provide any intermediate events.</p>
    </section3>

    <section3 topic='Completion' anchor='session-receiving-completion'>
      <p>The receivefax completion reason MUST be one of the <link url='#def-components-complete-reason'>core Rayo reasons</link> or <link url='#def-finish'>finish</link> (indicating that the document was fully received). Receivefax component completion provides a fax element only when a document was successfully received.</p>

      <p>The server MUST present the fax for consumption by the client by way of fax meta-data on the complete reason, including a URI at which the document may be fetched. It MUST provide url, resolution, file size &amp; page count data as specified on the <link url='#def-fax'>fax element</link>. In cases of partial receipt of a fax, a fax element MAY be returned in addition to the error completion reason.</p>
      <example caption="Component indicates it has completed due to being finished, providing the fax"><![CDATA[
<presence from='9f00061@call.shakespeare.lit/eh3u28'
        to='juliet@capulet.lit/courtyard'
        type='unavailable'>
  <complete xmlns='urn:xmpp:rayo:ext:1'>
    <finish xmlns='urn:xmpp:rayo:fax:complete:1'/>
    <fax xmlns='urn:xmpp:rayo:fax:complete:1' url='http://shakespere.lit/faxes/fax1.tiff' resolution='595x841' size='12287492817' pages='3'/>
    <metadata xmlns='urn:xmpp:rayo:fax:complete:1' name="fax-transfer-rate" value="10000" />
  </complete>
</presence>
      ]]></example>
    </section3>
  </section2>

  <section2 topic='Sending Faxes' anchor='session-receiving'>
    <p>Sending faxes can be achieved by using the Sendfax component. A conformant server MUST support image/tiff documents, and MAY also support others. A conformant server MUST support fetching documents via an HTTP URL and MAY support other URL schemes.</p>

    <example caption='Client sends a fax document to a call'><![CDATA[
<iq from='juliet@capulet.lit/balcony'
    to='9f00061@call.shakespeare.lit'
    type='set'
    id='h7ed2'>
  <sendfax xmlns='urn:xmpp:rayo:fax:1'>
    <document xmlns='urn:xmpp:rayo:fax:1' url='http://shakespere.lit/my_fax.tiff'/>
  </sendfax>
</iq>
    ]]></example>

    <p>Additionally, a sendfax component MAY include in its completion reason one or more <link url='#def-metadata'>&lt;metadata/&gt; elements</link> describing the result of transmitting the document, like so:</p>

    <example caption='Client finishes sending a fax document to a call'><![CDATA[
<presence from='9f00061@call.shakespeare.lit/eh3u28'
          to='juliet@capulet.lit/courtyard'
          type='unavailable'>
  <complete xmlns='urn:xmpp:rayo:ext:1'>
    <finish xmlns='urn:xmpp:rayo:fax:complete:1'/>
    <metadata xmlns='urn:xmpp:rayo:fax:complete:1' name="fax-transfer-rate" value="10000" />
  </complete>
</presence>
    ]]></example>
  </section2>
</section1>
<section1 topic='Formal Definition' anchor='def'>
  <section2 topic='Receivefax Element' anchor='def-receivefax'>
    <p>Instructs the server to begin receiving a fax.</p>
    <p>The &lt;receivefax/&gt; element MUST be empty.</p>
    <p>The &lt;receivefax/&gt; element has no attributes.</p>
  </section2>

  <section2 topic='Sendfax Element' anchor='def-sendfax'>
    <p>Instructs the server to begin transmitting a fax.</p>
    <p>The &lt;sendfax/&gt; element MUST be empty.</p>
    <p>The &lt;sendfax/&gt; element has no attributes.</p>
  </section2>

  <section2 topic='Fax Element' anchor='def-fax'>
    <p>Provides the result of a received fax, as a reference to its location.</p>
    <p>The &lt;fax/&gt; element MUST be empty.</p>
    <p>The attributes of the &lt;fax/&gt; element are as follows.</p>
    <table caption='Attributes of Fax Element'>
      <tr>
        <th>Attribute</th>
        <th>Definition</th>
        <th>Possible Values</th>
        <th>Inclusion</th>
      </tr>
      <tr>
        <td>url</td>
        <td>Indicates the URL at which the fax is made available.</td>
        <td>A valid URI.</td>
        <td>REQUIRED</td>
      </tr>
      <tr>
        <td>resolution</td>
        <td>Indicates the resolution of the received fax.</td>
        <td>A string in MxN format, where M and N are integers in pixels.</td>
        <td>REQUIRED</td>
      </tr>
      <tr>
        <td>pages</td>
        <td>Indicates the number of pages in the received fax.</td>
        <td>An integer.</td>
        <td>REQUIRED</td>
      </tr>
      <tr>
        <td>size</td>
        <td>Indicates the filesize of the received fax.</td>
        <td>A positive integer in bytes.</td>
        <td>REQUIRED</td>
      </tr>
    </table>
  </section2>

  <section2 topic='Document Element' anchor='def-document'>
    <p>Provides data for a document to be sent as a fax.</p>
    <p>The &lt;document/&gt; element MUST be empty.</p>
    <p>The attributes of the &lt;document/&gt; element are as follows.</p>
    <table caption='Attributes of Document Element'>
      <tr>
        <th>Attribute</th>
        <th>Definition</th>
        <th>Possible Values</th>
        <th>Inclusion</th>
      </tr>
      <tr>
        <td>url</td>
        <td>Indicates the URL at which the document to send is available.</td>
        <td>A valid URI.</td>
        <td>REQUIRED</td>
      </tr>
      <tr>
        <td>identity</td>
        <td>Indicates the identity from which the fax should appear to be sent.</td>
        <td>A phone number string in E.164 format.</td>
        <td>OPTIONAL</td>
      </tr>
      <tr>
        <td>header</td>
        <td>The header line to add to each page of the transmitted fax.</td>
        <td>A string.</td>
        <td>OPTIONAL</td>
      </tr>
      <tr>
        <td>pages</td>
        <td>The (set of) range of pages of the document to transmit.</td>
        <td>A string (or set of strings separated by ',') in the format M[-N], where M and N are integers and the dash and second integer are optional. The set is combinatory and dash-separated integers signify a range of pages. The index is one-based.</td>
        <td>OPTIONAL</td>
      </tr>
    </table>
  </section2>

  <section2 topic='Metadata Element' anchor='def-metadata'>
    <p>Provides implementation-specific key-value pairs of metadata regarding the transmission or receipt of a fax document.</p>
    <p>The &lt;metadata/&gt; element MUST be empty.</p>
    <p>The attributes of the &lt;metadata/&gt; element are as follows.</p>
    <table caption='Attributes of Metadata Element'>
      <tr>
        <th>Attribute</th>
        <th>Definition</th>
        <th>Inclusion</th>
      </tr>
      <tr>
        <td>name</td>
        <td>A token giving the name by which the metadata may be known.</td>
        <td>REQUIRED</td>
      </tr>
      <tr>
        <td>value</td>
        <td>The string value of the named metadata.</td>
        <td>REQUIRED</td>
      </tr>
    </table>
  </section2>

  <section2 topic='Finish Element' anchor='def-finish'>
    <p>Indicates that the component came to an end due to the document being received successfully.</p>
    <p>The &lt;finish/&gt; element MUST be empty.</p>
    <p>The &lt;finish/&gt; element has no attributes.</p>
  </section2>
</section1>
<section1 topic='Determining Support' anchor='support'>
  <p>If a Rayo server supports Rayo Fax, it MUST advertise that fact by returning a feature of "urn:xmpp:rayo:fax:1" &VNOTE; in response to a &xep0030; information request.</p>
  <example caption="Service Discovery Information Request - Client to Server"><![CDATA[
<iq from='kingclaudius@shakespeare.lit/castle'
    id='disco1'
    to='call.rayo.org'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
  ]]></example>
  <example caption="Service Discovery Information Response - Client to Server"><![CDATA[
<iq from='call.rayo.org'
    id='disco1'
    to='kingclaudius@shakespeare.lit/castle'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <feature var='urn:xmpp:rayo:1'/>
    <feature var='urn:xmpp:rayo:fax:1'/>
  </query>
</iq>
  ]]></example>
  <p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
</section1>
<section1 topic='Implementation Notes' anchor='impl'>
  <p>A server MUST document any cases where its behaviour differs from that in this specification (such as lack of support for particular options/components/etc) and return an error whenever a command is not understood. A server MUST NOT silently ignore any instructions.</p>
</section1>
<section1 topic='Security Considerations' anchor='security'>
  <p>This document introduces no additional security considerations above and beyond those defined in the documents on which it depends.</p>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document requires no interaction with &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
    <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
    <p>This specification defines the following XML namespaces:</p>
    <ul>
      <li>urn:xmpp:rayo:fax:1</li>
      <li>urn:xmpp:rayo:fax:complete:1</li>
    </ul>
    <p>The &REGISTRAR; includes the foregoing namespaces in its registry at &NAMESPACES;, as governed by &xep0053;.</p>
  </section2>
  <section2 topic='Namespace Versioning' anchor='registrar-versioning'>
    <p>If the protocol defined in this specification undergoes a major revision that is not fully backward-compatible with an older version, or that contains significant new features, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of <cite>XEP-0053</cite>.</p>
  </section2>
</section1>
<section1 topic='XML Schema' anchor='schema'>
  <section2 topic='Rayo Fax' anchor='schema-rayo-fax'>
    <code><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  targetNamespace="urn:xmpp:rayo:fax:1"
  xmlns:tns="urn:xmpp:rayo:fax:1"
  elementFormDefault="qualified"
  xmlns:core="urn:xmpp:rayo:1">

  <annotation>
    <documentation>
      The protocol documented by this schema is defined at http://rayo.org/xep
    </documentation>
  </annotation>

  <!-- Fax receipt command -->
  <element name="receivefax" type="core:empty">
    <annotation>
      <documentation>
        Instructs the server to begin receiving a fax.
      </documentation>
    </annotation>
  </element>

  <!-- Fax transmission command -->
  <element name="sendfax" type="core:empty">
    <annotation>
      <documentation>
        Instructs the server to begin transmitting a fax.
      </documentation>
    </annotation>
  </element>

  <!-- Fax document data -->
  <element name="document" type="core:empty">
    <annotation>
      <documentation>
        Provides the result of a received fax, including a reference to its location.
      </documentation>
    </annotation>
    <attribute name="url" type="anyURI" use="required">
      <annotation>
        <documentation>
          Indicates the URL at which the document to send is available.
        </documentation>
      </annotation>
    </attribute>
    <attribute name="identity" type="string" use="optional">
      <annotation>
        <documentation>
          Indicates the identity from which the fax should appear to be sent.
        </documentation>
      </annotation>
    </attribute>
    <attribute name="header" type="string" use="optional">
      <annotation>
        <documentation>
          The header line to add to each page of the transmitted fax.
        </documentation>
      </annotation>
    </attribute>
    <attribute name="pages" type="string" use="optional">
      <annotation>
        <documentation>
          A string (or set of strings separated by ',') in the format M[-N], where M and N are integers and the dash and second integer are optional. The set is combinatory and dash-separated integers signify a range of pages. The index is one-based.
        </documentation>
      </annotation>
    </attribute>
  </element>
</schema>
    ]]></code>
  </section2>
  <section2 topic='Rayo Fax Complete' anchor='schema-fax-complete'>
    <code><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
  targetNamespace="urn:xmpp:rayo:fax:complete:1"
  xmlns:tns="urn:xmpp:rayo:fax:complete:1"
  elementFormDefault="qualified"
  xmlns:core="urn:xmpp:rayo:1">

  <annotation>
    <documentation>
      The protocol documented by this schema is defined at http://rayo.org/xep
    </documentation>
  </annotation>

  <!-- Received Fax data -->
  <element name="fax" type="core:empty">
    <annotation>
      <documentation>
        Provides the result of a received fax, including a reference to its location.
      </documentation>
    </annotation>
    <attribute name="url" type="anyURI" use="required">
      <annotation>
        <documentation>
          Indicates the URL at which the fax is made available.
        </documentation>
      </annotation>
    </attribute>
    <attribute name="resolution" type="string" use="required">
      <annotation>
        <documentation>
          Indicates the resolution of the received fax in MxN format, where M and N are integers in pixels.
        </documentation>
      </annotation>
    </attribute>
    <attribute name="pages" type="nonNegativeInteger" use="required">
      <annotation>
        <documentation>
          Indicates the number of pages in the received fax.
        </documentation>
      </annotation>
    </attribute>
    <attribute name="size" type="long" use="required">
      <annotation>
        <documentation>
          Indicates the filesize (in bytes) of the received fax.
        </documentation>
      </annotation>
    </attribute>
  </element>

  <complexType name="metadataType">
    <attribute name="name" type="token" use="required">
      <annotation>
        <documentation>
          A token giving the name by which the metadata may be known.
        </documentation>
      </annotation>
    </attribute>
    <attribute name="value" type="string" use="required">
      <annotation>
        <documentation>
          The string value of the named metadata.
        </documentation>
      </annotation>
    </attribute>
  </complexType>

  <!-- Finish reason -->
  <element name="finish" type="core:empty">
    <annotation>
      <documentation>
        Indicates that the component came to an end due to the document being received successfully.
      </documentation>
    </annotation>
  </element>
</schema>
    ]]></code>
  </section2>
</section1>
<section1 topic='Acknowledgements' anchor='acknowledgements'>
  <p>The authors would like to acknowledge the input of teams at Mojo Lingo and Grasshopper in the development of this specification.</p>

  <p>Specific individuals who have contributed to the specification or to software significant to its completion include:</p>
  <ul>
    <li>Ben Langfeld</li>
    <li>Chris Rienzo</li>
  </ul>
</section1>
</xep>
