<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>File Information Sharing</title>
  <abstract>This document specifies a simple extension to existing protocols that allows an entity to request information about files.</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>0329</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0234</spec>
    <spec>XEP-0059</spec>
    <spec>XEP-0265</spec>
  </dependencies>
  <supersedes>
    <spec>XEP-0135</spec>
  </supersedes>
  <supersededby/>
  <shortname>fis</shortname>
  <author>
      <firstname>Jefry</firstname>
      <surname>Lagrange</surname>
      <email>jefry.reyes@gmail.com</email>
      <jid>j.lagrange@jabber.org</jid>
  </author>
  
  <author>
    <firstname>Lance</firstname>
    <surname>Stout</surname>
    <email>lance@andyet.com</email>
    <jid>lance@lance.im</jid>
  </author>

  <revision>
    <version>0.4.1</version>
    <date>2020-06-14</date>
    <initials>fs</initials>
    <remark>Fix example 7, remove superfluous 'node' attribute</remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2017-09-11</date>
    <initials>XEP Editor (jwi)</initials>
    <remark>Defer due to lack of activity.</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2016-08-07</date>
    <initials>egp</initials>
    <remark><p>Updated the <span class="ref"><link url="https://xmpp.org/extensions/xep-0234.html">Jingle File Transfer (XEP-0234)</link></span> <note>XEP-0234: Jingle File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0234.html">https://xmpp.org/extensions/xep-0234.html</link>&gt;.</note> referenced version to 0.16 or higher.</p></remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2013-11-19</date>
    <initials>jl</initials>
    <remark><p>Corrected namespace to use XSF format.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2013-06-11</date>
    <initials>psa</initials>
    <remark><p>Initial published version approved by the XMPP Council.</p></remark>
  </revision>
  <revision>
    <version>0.0.4</version>
    <date>2013-01-26</date>
    <initials>jl</initials>
    <remark>Third draft</remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p>XMPP extensions provide ways of transferring files between peers (such as <span class="ref"><link url="https://xmpp.org/extensions/xep-0234.html">Jingle File Transfer (XEP-0234)</link></span> <note>XEP-0234: Jingle File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0234.html">https://xmpp.org/extensions/xep-0234.html</link>&gt;.</note> and <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>). However, file transfer is currently limited to needing that the transfer be initiated by the hosting entity. The <span class="ref"><link url="https://xmpp.org/extensions/xep-0234.html">Jingle File Transfer (XEP-0234)</link></span> <note>XEP-0234: Jingle File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0234.html">https://xmpp.org/extensions/xep-0234.html</link>&gt;.</note> extension, provides for a way to request files, but it requires the requesting entity to have information about the file being requested, so that it can be uniquely identified. </p>
<p>This document defines an extension which allows the request of information of files being offered by a hosting entity so they can later be requested in a file transfer; If the requesting entity is interested in the file.</p>
<p><span class="ref"><link url="https://xmpp.org/extensions/xep-0135.html">File Sharing (XEP-0135)</link></span> <note>XEP-0135: File Sharing &lt;<link url="https://xmpp.org/extensions/xep-0135.html">https://xmpp.org/extensions/xep-0135.html</link>&gt;.</note> is a previous extention that attempted to solve the same problem as this one, but unfortunetly it didn't generate much interest and it got deprecated. This extention aims be a modern replacement for XEP-0135.</p>
<p>IRC users have been able to bypass the limitations of the protocol by using bots that provide information of files and initiate transfer on command. A major downside of this method is that not every user is capable of sharing its files. The aim of this document is to provide a similar functionality while making it easier for users to offer and request information about files. </p>
<p>Microsoft's MSN proprietary IM client, used to provide similar functionality using "Sharing Folders", but this was replaced by Windows Live SkyDrive </p>
</section1>
<section1 topic="Requirements" anchor="reqs">
  <ol>
    <li>Enable a requesting entity to traverse the shared directory of an offering entity (REQUIRED)</li>
    <li>Enable a requesting entity to get detailed information about files. (REQUIRED)</li>
  </ol>
</section1>
<section1 topic="Assumptions" anchor="assump">
<!-- Maybe make this into a list -->
    <p> This protocol assumes the existence of one or more shared directories (either virtual or physical). The hosting entity must not advertise empty directories. The hosting entity is responsible of maintaining the structure of those directories (such as not allowing two files with the same name and preventing cycles within directories). The hosting entity is in no way required to present the same shared directories to different requesters. In fact, the reason multiple share directories are allowed, is to make it easier for implementers to manage permissions of who can see what files.</p>
</section1>
<section1 topic="Getting Information About Files " anchor="disco">
  <section2 topic="Traversing Files" anchor="traver">
      <p>If a requesting entity wishes to know what files are being shared by an offering entity, it can do so by sending the following query:</p>
      <example caption="Requester queries the root of the shared folder"><![CDATA[
<iq type='get'
    from='juliet@capulet.com/chamber'
    to='romeo@montague.net/home'
    id='1234'>
  <query xmlns="urn:xmpp:fis:0" />
</iq>]]></example>
      <p> If the offering entity wishes to share files with the requesting entity, it may respond with a list of shared folders. It MUST not include any files in this response.</p>
      <example caption="The offering entity responds with shared directories"><![CDATA[
<iq type='result'
    from='romeo@montague.net/home'
    to='juliet@capulet.com/chamber'
    id='1234'>
  <query xmlns="urn:xmpp:fis:0">
    <directory name='documents'/>
    <directory name='pics'/>
    <directory name='audio'/>
  </query>
</iq>]]></example>
      <p>if the offering entity has no files to offer</p>
      <example caption="The offering entity responds with no files"><![CDATA[
<iq type='result'
    from='romeo@montague.net/home'
    to='juliet@capulet.com/chamber'
    id='1234'>
  <query xmlns="urn:xmpp:fis:0" />
</iq>]]></example>
      <p>Requesting the list of files and directories within a directory.</p>
      <example caption="The requesting entity wants to know about a particular directory"><![CDATA[
<iq type='get'
    from='juliet@capulet.com/chamber'
    to='romeo@montague.net/home'
    id='1235'>
  <query xmlns="urn:xmpp:fis:0" node="documents" />
</iq>]]></example>
      <p>When replying with a list of files, the offering entity can choose to either reply with verbose information on the file using the file attributes defined by <span class="ref"><link url="https://xmpp.org/extensions/xep-0234.html">Jingle File Transfer (XEP-0234)</link></span> <note>XEP-0234: Jingle File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0234.html">https://xmpp.org/extensions/xep-0234.html</link>&gt;.</note> or it may reply only with the 'name' attribute, which is required and MUST be included in every response.</p>
      <p>It is RECOMENDED, when the list files to be sent is small, that a verbose response be made (in order to avoid going back and forth requesting information), and that a non-verbose reponse be made otherwise. This recomendation is made to save bandwidth.</p>
      <example caption="The offering entity replies with information about a particular directory"><![CDATA[
<iq type='result'
    from='romeo@montague.net/home'
    to='juliet@capulet.com/chamber'
    id='1235'>
  <query xmlns="urn:xmpp:fis:0" node="documents">
    <file xmlns='urn:xmpp:jingle:apps:file-transfer:4'>
      <name>test.txt</name>
      <date>1969-07-21T02:56:15Z</date>
      <desc>This is a test. If this were a real file...</desc>
      <range/>
      <size>1022</size>
      <hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>552da749930852c69ae5d2141d3766b1</hash>
    </file>
    <file xmlns='urn:xmpp:jingle:apps:file-transfer:4'>
      <name>test2.txt</name>
    </file>
    <directory name="secret docs" />
  </query>
</iq>]]></example>
      <p>If the requesting entity wants to get detailed information about a file. It can do so by providing its full path.</p>
      <example caption="The requesting entity wants to know about a particular file"><![CDATA[
<iq type='get'
    from='juliet@capulet.com/chamber'
    to='romeo@montague.net/home'
    id='1236'>
  <query xmlns="urn:xmpp:fis:0" node="documents/test2.txt" />
</iq>]]></example>
      <example caption="The offering entity responds with more information"><![CDATA[
<iq type='result'
    from='romeo@montague.net/home'
    to='juliet@capulet.com/chamber'
    id='1236'>
  <query xmlns="urn:xmpp:fis:0">
    <file xmlns='urn:xmpp:jingle:apps:file-transfer:4'>
      <name>test2.txt</name>
      <size>1000</size>
    </file>
  </query>
</iq>]]></example>
  </section2>
</section1>
<section1 topic="Bandwidth Considerations" anchor="bandwidth">
    <p> If a considerable amount of files are being shared by the offering entity, it may be the case that the offering entity response might be too be for the server to handle; As there might be a limitation on the size of the stanzas in the current stream. In order to solve this, extensions have been devised and their implementation are hereby recommended along with the implementation of this extension.</p>
    <section2 topic="Using Result Set Management" anchor="resultset">
        <p><span class="ref"><link url="https://xmpp.org/extensions/xep-0059.html">Result Set Management (XEP-0059)</link></span> <note>XEP-0059: Result Set Management &lt;<link url="https://xmpp.org/extensions/xep-0059.html">https://xmpp.org/extensions/xep-0059.html</link>&gt;.</note> defines a way of limiting the results of a request. There are some considerations to use result sets along with this extension.</p>
        <p>First, it is defined that the requesting entity is the one that sets the limit of the number of items that can be replied. So it is up to the requesting entity to choose a sensible number.</p>
        <p>Second, since this protocol defines a way of handling the directory tree structure by allowing file tags to be children of a directory tags, it becomes difficult to define items for Result Set Management. Therefore, when responding to a request, the offering entity MUST NOT send directory tags with files as their children.         </p>
    </section2>
    <section2 topic="Out of Band Transfer" anchor="out-of-band">
        <p>One obvious way to overcome the limitations of sending large stanzas in-band, is to transfer that information out of band. <span class="ref"><link url="https://xmpp.org/extensions/xep-0265.html">Out-of-Band Stream Data (XEP-0265)</link></span> <note>XEP-0265: Out-of-Band Stream Data &lt;<link url="https://xmpp.org/extensions/xep-0265.html">https://xmpp.org/extensions/xep-0265.html</link>&gt;.</note> could be used for that purpose. It is hereby RECOMMENDED its implementation when the offering entity has a massive amount of files that would not be practical to advertise in-band.</p>
        <p>It is further recommended that when using XEP-0265, the entire directory structure, along with all the files in the shared folder and subfolders, be exchanged in one single reply. Also, all the files attributes should be included. This is to avoid wasting bandwidth initiating out of band streams going back and forth. </p>
    </section2>
</section1>
<section1 topic="Implementation Notes" anchor="implementation">
    <section2 topic="File identification" anchor="file_id">
        <p> As it was previously discussed, when requesting detailed information about a file, only the "name" attribute is required, but it is strongly RECOMMENDED that the hash attribute be included, in order to reduce the chances of sending the wrong file. When requesting the file to be transferred using <span class="ref"><link url="https://xmpp.org/extensions/xep-0234.html">Jingle File Transfer (XEP-0234)</link></span> <note>XEP-0234: Jingle File Transfer &lt;<link url="https://xmpp.org/extensions/xep-0234.html">https://xmpp.org/extensions/xep-0234.html</link>&gt;.</note>, the information that must be provided has to identify the file uniquely. It is then RECOMMENDED that when requesting a file, the full path of the file in the shared folder be included in the "name" attribute.</p>
        <example><![CDATA[
<iq type='get'
    from='juliet@capulet.com/chamber'
    to='romeo@montague.net/home'
    id='1237'>
  <jingle xmlns='urn:xmpp:jingle:1'
          action='session-initiate'
          initiator='juliet@capulet.com/chamber'
          sid='uj3b2'>
    <content creator='initiator' name='a-file-request' senders='responder'>
      <description xmlns='urn:xmpp:jingle:apps:file-transfer:4'>
        <file>
          <name>pics/test4.png</name>
          <size>10740</size>
        </file>
      </description>
    </content>
  </jingle>
</iq>]]></example>
    </section2>
    <section2 topic="File Sharing in MUCs" anchor="fis_muc">
 <p>For the most part, discovering files in a MUC is exactly the same as what has been described in this document. However, it is RECOMMENDED that a participant in a MUC should have a single shared folder associated with the entire room, as opposed to advertise different files to different participants of the room. This is to reduce the complexity of the client software. Also, due to volatile nature of the participants in a room, keeping track of permissions is more trouble than what it is worth.</p>
    </section2>
</section1>
<section1 topic="Security Considerations" anchor="security">
    <p>A denial of service is possible by repeatedly requesting files. Implementers are advised to take this into consideration and include queues and limits into their implementations.</p>
</section1>
</xep>
