Hey, this is my first development update! As some of you might already know from my last blog post, my Google Summer of Code project is implementing Stateless File Sharing for Dino. This is my first XMPP project and as such, I had to learn very basic things about it. In my blog posts I’ll try to document the things I learned, with the idea that it might help someone else in the future. I won’t refrain from explaining terms you might take for granted in the XMPP world.

The idea behind Stateless File Sharing

Currently there are mutiple ways to send files via XMPP. Some of those methods initiate the file transfers in very different ways. This makes it difficult to add shiny new features like blurred previews of images, because we would need to implement that for each file transfer individually.

What we want is a unified initiation for file transfers. In that initiation, “sources” should be specified that tell the receiver how they can access that file.

Relevant XEPs

The core of the XMPP protocol is very slim, defining only general ways of communicating data. It is build to be extensible, and XEP are exactly that: XMPP Extension Protocols.

Stateless File Sharing is XEP-0447. It depends on XEP-0446, which defines the metadata that should be sent alongside a file. XEP-0446 in turn depends on XEP-0300, where the integration of hashes is specified, and XEP-0264, which defines the usage of thumbnails.

Stanzas

This is a term that comes up everywhere if you dive into XMPP technical information. Since it confused be for a while, here a quick rundown.

Stanzas are the basic form of communication between XMPP clients and servers. There are different types of them, but they are all encoded with XML. As such, they inherit XML’s structure.

An XML element can be viewed as a tree. See for instance the format example for the file metadata element (XEP-0446):

<file xmlns='urn:xmpp:file:metadata:0'>
    <media-type>text/plain</media-type>
    <name>test.txt</name>
    <date>2015-07-26T21:46:00+01:00</date>
    <size>6144</size>
    <hash xmlns='urn:xmpp:hashes:2'
          algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>
</file>

The root element is called ‘file’, and has only one attribute “xmlns”. Each attribute has a value assigned, in this case its ‘urn:xmpp:file:metadata:0’. The ‘file’ element also has child elements, all containing a text body. Only the “hash” child element has an additional attribute.

Progress (as of 29/06/2022)

I’m now familiar with how Dino represents Stanzas. I’ve created the base struct for the file metadata element (XEP-0446) and serialize, send, and deserialize it. So far I simply integrate the code into the http file transfer code, detaching from it will come later.

You can track my progress on my stateless-file-sharing branch!