<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Tree Transfer Stream Initiation Profile</title>
  <abstract>A profile describing metadata for transferring trees of files using stream inititation.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0105</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XEP-0095</spec>
    <spec>XEP-0096</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>si-treetransfer</shortname>
  
  <author>
    <firstname>Ryan</firstname>
    <surname>Eatmon</surname>
    <email>reatmon@jabber.org</email>
    <jid>reatmon@jabber.org</jid>
  </author>

  <revision>
    <version>0.3.1</version>
    <date>2018-11-03</date>
    <initials>pep</initials>
    <remark>Fix a bunch of typos, batch-style.</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2003-09-22</date>
    <initials>rwe</initials>
    <remark>Updated directory structure from flat to hierarchical.</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2003-07-23</date>
    <initials>rwe</initials>
    <remark>Fixed bad data types in the schema.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2003-07-09</date>
    <initials>rwe</initials>
    <remark>Initial version.</remark>
  </revision>
</header>
<section1 topic="Introduction">
  <p>File transfers of entire trees require a lot more metadata and prior setup to link paths to files with unique ids so that clients can track them. This profile provides a more robust method of defining that metadata so that directory trees can be transfered.</p>
</section1>
<section1 topic="Requirements">
  <ul>
    <li>Provide a full featured set of information that is applicable to tree transfers.</li>
    <li>Meta-data that is to be provided:
      <ul>
        <li>number of files</li>
        <li>size of entire tree</li>
        <li>list of files and stream ids</li>
      </ul>
    </li>
  </ul>
</section1>
<section1 topic="Usage">
  <p>The tree transfer profile is in the "http://jabber.org/protocol/si/profile/tree-transfer" namespace. The profile is fairly simple: it consists of the root element with child elements that specify a directory structure of files with stream ids that will be used for each file.</p>
  <p>This profile requires support for the File Transfer profile described in <span class="ref"><link url="https://xmpp.org/extensions/xep-0096.html">SI File Transfer (XEP-0096)</link></span> <note>XEP-0096: SI File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0096.html">https://xmpp.org/extensions/xep-0096.html</link>&gt;.</note>. Once you have accepted this SI, a new SI using the File Transfer profile will be offered for each file in the tree. This profile provides a mapping of files with paths and reserved stream ids which will be used to auto-accept a File Transfer SI that uses that same stream id from the sender.</p>
  <p>The root element is &lt;tree&gt; and has two attributes. The attributes are used only during the offer stage of stream initiation:</p>
  <ul>
    <li><em>size</em> - The size, in bytes, of all of the files to be sent.</li>
    <li><em>numfiles</em> - The number of files/File Transfer SIs that are in the tree.</li>
  </ul>
  <p>The <em>size</em> and <em>numfiles</em> attributes MUST be present in the profile.</p>
  <p>The only possible child element of the root is &lt;directory/&gt; since there are other specifications that handle single file transfers. The directory structure is sent in a hierarchical manner with nested &lt;directory/&gt; and/or &lt;file/&gt; tags. One or more &lt;file/&gt; elements will be sent, one for each file. One or more &lt;directory/&gt; elements will be sent, one for each directory.</p>
  <p>The &lt;directory/&gt; element has one attribute:</p>
  <ul>
    <li><em>name</em> - The name of the directory to create on the target system.</li>
  </ul>
  <p>The attribute is REQUIRED on each &lt;directory/&gt; element.</p>
  <p>The &lt;file/&gt; element has two attributes:</p>
  <ul>
    <li><em>sid</em> - The stream id that MUST be sent for the File Transfer SI.</li>
    <li><em>name</em> - The name of the file. The file should be saved to the same location in the target directory tree as the &lt;directory/&gt; hierarchy defines.</li>
  </ul>
  <p>Both attributes are REQUIRED on each &lt;file/&gt; element. The total number of &lt;file&gt; elements MUST equal the numfiles attribute sent in the &lt;tree/&gt; element.</p>
  <p>The stream-method that is accepted for a Tree Profile SI MUST be remembered and the subsequent File Transfer SIs MUST NOT provide a Feature Negotiation packet. The stream-method has already been chosen and should be used for all of the streams.</p>
  <p>Implementations of this profile MUST support <span class="ref"><link url="https://xmpp.org/extensions/xep-0095.html">Stream Initiation (XEP-0095)</link></span> <note>XEP-0095: Stream Initiation &lt;<link url="https://xmpp.org/extensions/xep-0095.html">https://xmpp.org/extensions/xep-0095.html</link>&gt;.</note> and XEP-0096.</p>
</section1>
<section1 topic="Examples">
  <example caption="Profile Usage in Stream Initiation Offer"><![CDATA[
<iq type='set' id='offer1' to='receiver@jabber.org/resource'>
  <si
    xmlns='http://jabber.org/protocol/si'
    id='a0'
    profile='http://jabber.org/protocol/si/profile/tree-transfer'>
    <tree
      xmlns='http://jabber.org/profile/si/profile/tree-transfer'
      numfiles='9'
      size='80500'>
      <directory name='cd_collection'>
        <file sid='ft1' name='coll.index'/>
        <directory name='album1'>
          <file sid='ft2' name='song1.mp3'/>
          <file sid='ft3' name='song2.mp3'/>
          <file sid='ft4' name='song3.mp3'/>
          <file sid='ft5' name='song4.mp3'/>
        </directory>
        <directory name='album2'>
          <file sid='ft6' name='song1.mp3'/>
          <file sid='ft7' name='song2.mp3'/>
          <file sid='ft8' name='song3.mp3'/>
          <file sid='ft9' name='song4.mp3'/>
        </directory>
      </directory>
    </tree>
    <feature xmlns='http://jabber.org/protocol/feature-neg'>
      <x xmlns='jabber:x:data'>
        <field var='stream-method' type='list-single'>
          <option><value>http://jabber.org/protocol/bytestreams</value></option>
          <option><value>http://jabber.org/protocol/ibb</value></option>
        </field>
      </x>
    </feature>
  </si>
</iq>
]]></example>
  <example caption="Simple Profile Usage in Stream Initiation Result"><![CDATA[
<iq type='result' to='sender@jabber.org/resource' id='offer1'>
  <si xmlns='http://jabber.org/protocol/si'>
    <feature xmlns='http://jabber.org/protocol/feature-neg'>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='stream-method'>
          <value>http://jabber.org/protocol/bytestreams</value>
        </field>
      </x>
    </feature>
  </si>
</iq>
]]></example>
  <example caption="Subsequent File Transfer Offer"><![CDATA[
<iq type='set' id='offer2' to='receiver@jabber.org/resource'>
  <si xmlns='http://jabber.org/protocol/si'
      id='ft1'
      mime-type='text/plain'
      profile='http://jabber.org/protocol/si/profile/file-transfer'>
    <file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
          name='coll.index'
          size='500'/>
  </si>
</iq>
]]></example>
  <example caption="Subsequent File Transfer Result"><![CDATA[
<iq type='result' to='sender@jabber.org/resource' id='offer2'>
  <si xmlns='http://jabber.org/protocol/si'/>
</iq>
]]></example>
  <p>Above is repeated for ft2, ft3, etc...</p>
</section1>
<section1 topic="IANA Considerations">
  <p>
    No interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note> is required as a result of this document.
  </p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>
    The profile described in this document will be registered with <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> as a valid Stream
    Initiation profile.
  </p>
</section1>
<section1 topic="XML Schema">
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/si/profile/tree-transfer'
    xmlns='http://jabber.org/protocol/si/profile/tree-transfer'
    elementFormDefault='qualified'>

  <xs:element name='tree'>
    <xs:complexType>
      <xs:attribute name='numfiles' use='required' type='xs:integer'/>
      <xs:attribute name='size' use='required' type='xs:integer'/>
      <xs:element ref='directory' minOccurs='0' maxOccurs='1'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='directory'>
    <xs:complexType>
      <xs:attribute name='name' use='required' type='xs:string'/>
      <xs:element ref='directory' minOccurs='0' maxOccurs='unbounded'/>
      <xs:element ref='file' minOccurs='0' maxOccurs='unbounded'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='file'>
    <xs:complexType>
      <xs:attribute name='name' use='required' type='xs:string'/>
      <xs:attribute name='sid' use='required' type='xs:string'/>
    </xs:complexType>
  </xs:element>

</xs:schema>
]]></code>
</section1>
</xep>
