mirror of
https://github.com/moparisthebest/xeps
synced 2024-11-24 10:12:19 -05:00
de16d33554
git-svn-id: file:///home/ksmith/gitmigration/svn/xmpp/trunk@47 4b5297f7-1745-476d-ba37-a9c6900126ab
285 lines
16 KiB
XML
285 lines
16 KiB
XML
<?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>vCard-Based Avatars</title>
|
|
<abstract>This document provides historical documentation of a vCard-based protocol for exchanging user avatars.</abstract>
|
|
&LEGALNOTICE;
|
|
<number>0153</number>
|
|
<status>Active</status>
|
|
<type>Historical</type>
|
|
<jig>Standards JIG</jig>
|
|
<approver>Council</approver>
|
|
<dependencies>
|
|
<spec>XMPP Core</spec>
|
|
<spec>XMPP IM</spec>
|
|
<spec>XEP-0054</spec>
|
|
</dependencies>
|
|
<supersedes/>
|
|
<supersededby/>
|
|
<shortname>vcard-avatar</shortname>
|
|
<schemaloc>
|
|
<url>http://www.xmpp.org/schemas/vcard-avatar.xsd</url>
|
|
</schemaloc>
|
|
&stpeter;
|
|
<revision>
|
|
<version>1.0</version>
|
|
<date>2006-08-16</date>
|
|
<initials>psa</initials>
|
|
<remark>Per a vote of the Jabber Council, advanced status to Active.</remark>
|
|
</revision>
|
|
<revision>
|
|
<version>0.3</version>
|
|
<date>2006-01-12</date>
|
|
<initials>psa</initials>
|
|
<remark>Collected all syntax rules into dedicated section; incorporated feedback from implementation experience; adjusted text regarding base64 encoding.</remark>
|
|
</revision>
|
|
<revision>
|
|
<version>0.2</version>
|
|
<date>2005-10-18</date>
|
|
<initials>psa</initials>
|
|
<remark>Changed 8k limit from MUST NOT to SHOULD NOT; specified that client should publish new presence stanza if it obtains an avatar image after sending an empty photo element; specified that the update child should be included in directed presence stanzas; more clearly specified Base64 rules.</remark>
|
|
</revision>
|
|
<revision>
|
|
<version>0.1</version>
|
|
<date>2005-06-16</date>
|
|
<initials>psa</initials>
|
|
<remark>Initial JEP version.</remark>
|
|
</revision>
|
|
<revision>
|
|
<version>0.0.3</version>
|
|
<date>2005-06-14</date>
|
|
<initials>psa</initials>
|
|
<remark>Changed type from Informational to Historical, adjusted text accordingly.</remark>
|
|
</revision>
|
|
<revision>
|
|
<version>0.0.2</version>
|
|
<date>2005-06-13</date>
|
|
<initials>psa</initials>
|
|
<remark>Specified that the image data is actually Base64 encoded.</remark>
|
|
</revision>
|
|
<revision>
|
|
<version>0.0.1</version>
|
|
<date>2005-06-09</date>
|
|
<initials>psa</initials>
|
|
<remark>First draft.</remark>
|
|
</revision>
|
|
</header>
|
|
<section1 topic='Introduction' anchor='intro'>
|
|
<p>There exist several proposed protocols for communicating user avatar information over Jabber/XMPP (see &xep0008; and &xep0084;). This document describes another such protocol that is in use today on the Jabber/XMPP network. This document is historical and does not purport to propose a standards-track protocol. However, a future protocol may improve on the approach documented herein.</p>
|
|
</section1>
|
|
<section1 topic='Requirements' anchor='reqs'>
|
|
<p>The protocol described herein seems to have been designed with the following requirements in mind:</p>
|
|
<ul>
|
|
<li>Enable a user to store an avatar image in his or her vCard.</li>
|
|
<li>Provide notice of avatar changes via the &PRESENCE; stanza.</li>
|
|
<li>Enable a contact to retrieve a user's avatar image if the user is offline.</li>
|
|
<li>Enable a contact to retrieve a user's avatar image without requesting it of the user's particular client, thus preserving bandwidth.</li>
|
|
</ul>
|
|
</section1>
|
|
<section1 topic='Use Cases' anchor='usecases'>
|
|
<section2 topic='User Publishes Avatar' anchor='publish'>
|
|
<p>Before informing contacts of the user's avatar, the user's client first publishes the avatar data to the user's public vCard using the protocol defined in &xep0054;.</p>
|
|
<example caption="User's Client Publishes Avatar Data to vCard"><![CDATA[
|
|
<iq from='juliet@capulet.com'
|
|
type='set'
|
|
id='vc1'>
|
|
<vCard xmlns='vcard-temp'>
|
|
<BDAY>1476-06-09</BDAY>
|
|
<ADR>
|
|
<CTRY>Italy</CTRY>
|
|
<LOCALITY>Verona</LOCALITY>
|
|
<HOME/>
|
|
</ADR>
|
|
<NICKNAME/>
|
|
<N><GIVEN>Juliet</GIVEN><FAMILY>Capulet</FAMILY></N>
|
|
<EMAIL>jcapulet@shakespeare.lit</EMAIL>
|
|
<PHOTO>
|
|
<TYPE>image/jpeg</TYPE>
|
|
<BINVAL>
|
|
Base64-encoded-avatar-file-here!
|
|
</BINVAL>
|
|
</PHOTO>
|
|
</vCard>
|
|
</iq>
|
|
]]></example>
|
|
<example caption="User's Server Acknowledges Publish"><![CDATA[
|
|
<iq to='juliet@capulet.com' type='result' id='vc1'/>
|
|
]]></example>
|
|
<p>Next, the user's client computes the SHA1 hash of the avatar image data itself (not the base64-encoded version) in accordance with &rfc3174;. This hash is then included in the user's presence information as the XML character data of the <photo/> child of an &X; element qualified by the 'vcard-temp:x:update' namespace, as shown in the following example:</p>
|
|
<example caption="User's Client Includes Avatar Hash in Presence Broadcast"><![CDATA[
|
|
<presence from='juliet@capulet.com/balcony'>
|
|
<x xmlns='vcard-temp:x:update'>
|
|
<photo>sha1-hash-of-image</photo>
|
|
</x>
|
|
</presence>
|
|
]]></example>
|
|
<p>The user's server then broadcasts that presence information to all contacts who are subscribed to the user's presence information.</p>
|
|
</section2>
|
|
<section2 topic='Contact Retrieves Avatar' anchor='retrieve'>
|
|
<p>When the recipient's client receives the hash of the avatar image, it SHOULD check the hash to determine if it already has a cached copy of that avatar image. If not, it retrieves the sender's full vCard in accordance with the protocol flow describerd in <cite>XEP-0054</cite> (note that this request is sent to the user's bare JID, not full JID):</p>
|
|
<example caption="Contact's Client Requests User's vCard"><![CDATA[
|
|
<iq from='romeo@montague.net/orchard'
|
|
to='juliet@capulet.com'
|
|
type='get'
|
|
id='vc2'>
|
|
<vCard xmlns='vcard-temp'/>
|
|
</iq>
|
|
]]></example>
|
|
<example caption="Server Returns vCard on Behalf of User"><![CDATA[
|
|
<iq from='juliet@capulet.com'
|
|
to='romeo@montague.net/orchard'
|
|
type='result'
|
|
id='vc2'>
|
|
<vCard xmlns='vcard-temp'>
|
|
<BDAY>1476-06-09</BDAY>
|
|
<ADR>
|
|
<CTRY>Italy</CTRY>
|
|
<LOCALITY>Verona</LOCALITY>
|
|
<HOME/>
|
|
</ADR>
|
|
<NICKNAME/>
|
|
<N><GIVEN>Juliet</GIVEN><FAMILY>Capulet</FAMILY></N>
|
|
<EMAIL>jcapulet@shakespeare.lit</EMAIL>
|
|
<PHOTO>
|
|
<TYPE>image/jpeg</TYPE>
|
|
<BINVAL>
|
|
Base64-encoded-avatar-file-here!
|
|
</BINVAL>
|
|
</PHOTO>
|
|
</vCard>
|
|
</iq>
|
|
]]></example>
|
|
</section2>
|
|
</section1>
|
|
<section1 topic='Business Rules' anchor='bizrules'>
|
|
<section2 topic='Inclusion of Update Data in Presence' anchor='bizrules-presence'>
|
|
<p>The following rules apply to inclusion of the update child element (<x xmlns='vcard-temp:x:update'/>) in presence broadcasts:</p>
|
|
<ol>
|
|
<li><p>If a client supports the protocol defined herein, it MUST include the update child element in every presence broadcast it sends and SHOULD also include the update child in directed presence stanzas (e.g., directed presence sent when joining &xep0045; rooms).</p></li>
|
|
<li>
|
|
<p>If a client is not yet ready to advertise an image, it MUST send an empty update child element, i.e.:</p>
|
|
<example caption="User Is Not Ready to Advertise an Image"><![CDATA[
|
|
<presence>
|
|
<x xmlns='vcard-temp:x:update'/>
|
|
</presence>
|
|
]]></example>
|
|
</li>
|
|
<li>
|
|
<p>If there is no avatar image to be advertised, the photo element MUST be empty, i.e.:</p>
|
|
<example caption="No Image to be Advertised"><![CDATA[
|
|
<presence>
|
|
<x xmlns='vcard-temp:x:update'>
|
|
<photo/>
|
|
</x>
|
|
</presence>
|
|
]]></example>
|
|
<p>If the client subsequently obtains an avatar image (e.g., by updating or retrieving the vCard), it SHOULD then publish a new &PRESENCE; stanza with character data in the <photo/> element.</p>
|
|
</li>
|
|
<p>Note: This enables recipients to distinguish between the absence of an image (empty photo element) and mere support for the protocol (empty update child).</p>
|
|
</ol>
|
|
</section2>
|
|
<section2 topic='Downloading and Uploading the vCard' anchor='bizrules-vcard'>
|
|
<p>The following rules apply to downloading and uploading the vCard:</p>
|
|
<ol>
|
|
<li><p>A client MUST NOT advertise an avatar image without first downloading the current vCard. Once it has done this, it MAY advertise an image. However, a client MUST advertise an image if it has just uploaded the vCard with a new avatar image. In this case, the client MAY choose not to redownload the vCard to verify its contents.</p></li>
|
|
<li><p>Within a given session, a client MUST NOT attempt to upload a given avatar image more than once. The client MAY upload the avatar image to the vCard on login and after that MUST NOT upload the vCard again unless the user actively changes the avatar image.</p></li>
|
|
<li><p>The client MUST NOT poll for new versions of the user's vCard in order to determine whether to update the avatar image hash.</p></li>
|
|
</ol>
|
|
</section2>
|
|
<section2 topic='Multiple Resources' anchor='bizrules-resources'>
|
|
<p>Jabber/XMPP allows multiple resources to authenticate for the same JID simultaneously. This introduces the potential of conflict between the resources regarding the user's avatar image. The following rules apply when a client receives a presence broadcast from another resource of its own JID:</p>
|
|
<ol>
|
|
<li><p>If the presence stanza received from the other resource does not contain the update child element, then the other resource does not support vCard-based avatars. That resource could modify the contents of the vCard (including the photo element); because polling for vCard updates is not allowed, the client MUST stop advertising the avatar image hash. However, the client MAY reset its hash if all instances of non-conforming resources have gone offline.</p></li>
|
|
<li>
|
|
<p>If the presence stanza received from the other resource contains the update child element, then the other resource conforms to the protocol for vCard-based avatars. There are three possible scenarios:</p>
|
|
<ul>
|
|
<li><p>If the update child element is empty, then the other resource supports the protocol but does not have its own avatar image. Therefore the client can ignore the other resource and continue to broadcast the existing image hash.</p></li>
|
|
<li><p>If the update child element contains an empty photo element, then the other resource has updated the vCard with an empty BINVAL. Therefore the client MUST retrieve the vCard. If the retrieved vCard contains a photo element with an empty BINVAL, then the client MUST stop advertising the old image.</p></li>
|
|
<li><p>If the update child element contains a non-empty photo element, then the client MUST compare the image hashes. If the hashes are identical, then the client can ignore the other resource and continue to broadcast the existing image hash. If the hashes are different, then the client MUST NOT attempt to resolve the conflict by uploading its avatar image again. Instead, it MUST defer to the content of the retrieved vCard by resetting its image hash (see below) and providing that hash in future presence broadcasts.</p></li>
|
|
</ul>
|
|
</li>
|
|
</ol>
|
|
</section2>
|
|
<section2 topic='Resetting the Image Hash' anchor='bizrules-reset'>
|
|
<p>Resetting the image hash consists of the following steps:</p>
|
|
<ol>
|
|
<li><p>Immediately send out a presence element with an empty update child element (containing no photo element).</p></li>
|
|
<li><p>Download the vCard from the server.</p></li>
|
|
<li><p>If the BINVAL is empty or missing, advertise an empty photo element in future presence broadcasts.</p></li>
|
|
<li><p>If the BINVAL contains image data, calculate the hash of image and advertise that hash in future presence broadcasts.</p></li>
|
|
</ol>
|
|
</section2>
|
|
<section2 topic='XML Syntax' anchor='bizrules-xml'>
|
|
<p>The following rules apply to the XML syntax:</p>
|
|
<ol>
|
|
<li><p>The <PHOTO/> element SHOULD contain a <BINVAL/> child whose XML character data is Base64-encoded data for the avatar image.</p></li>
|
|
<li><p>The <PHOTO/> element SHOULD NOT contain an <EXTVAL/> that points to a URI for the image file.</p></li>
|
|
<li><p>The <PHOTO/> element MUST NOT contain the avatar image itself.</p></li>
|
|
<li><p>The <PHOTO/> element SHOULD contain a <TYPE/> child whose XML character data specifies the content-type of the image data. The XML character data SHOULD be "image/gif", "image/jpeg", or "image/png".</p></li>
|
|
<li><p>The <PHOTO/> element MUST NOT possess a 'mime-type' attribute.</p></li>
|
|
</ol>
|
|
</section2>
|
|
<section2 topic='Image Restrictions' anchor='bizrules-image'>
|
|
<p>The following rules apply to images:</p>
|
|
<ol>
|
|
<li><p>The image SHOULD use less than eight kilobytes (8k) of data; this restriction is to be enforced by the publishing client.</p></li>
|
|
<li><p>The image height and width SHOULD be between thirty-two (32) and ninety-six (96) pixels; the recommended size is sixty-four (64) pixels high and sixty-four (64) pixels wide.</p></li>
|
|
<li><p>The image SHOULD be square.</p></li>
|
|
<li><p>The image content type <note>The IANA registry of content types is located at <<link url='http://www.iana.org/assignments/media-types/'>http://www.iana.org/assignments/media-types/</link>>.</note> SHOULD be image/gif, image/jpeg, or image/png; support for the "image/png" content type is REQUIRED, support for the "image/gif" and "image/jpeg" content types is RECOMMENDED, and support for any other content type is OPTIONAL.</p></li>
|
|
<li><p>The image data MUST conform to the base64Binary datatype <note>See <<link url='http://www.w3.org/TR/xmlschema-2/#base64Binary'>http://www.w3.org/TR/xmlschema-2/#base64Binary</link>>.</note> and thus be encoded in accordance with Section 6.8 of &rfc2045;, which recommends that base64 data should have lines limited to at most 76 characters in length. However, any whitespace characters (e.g., '\r' and '\n') MUST be ignored.</p></li>
|
|
</ol>
|
|
</section2>
|
|
</section1>
|
|
<section1 topic='Implementation Notes' anchor='impl'>
|
|
<p>The XML character data of the <TYPE/> element is a hint. If the XML character data of the <TYPE/> specifies a content type that does not match the data provided in the <BINVAL/> element, the processing application MUST adhere to the content type of the actual image data and MUST ignore the <TYPE/>. If the <TYPE/> is something other than image/gif, image/jpeg, or image/png, it SHOULD be ignored.</p>
|
|
<p>If the image data exceeds the 8 KB restriction, the processing application SHOULD process the data.</p>
|
|
</section1>
|
|
<section1 topic='Security Considerations' anchor='security'>
|
|
<p>This document introduces no security considerations above and beyond those described in &rfc3920;, &rfc3921;, and &xep0054;.</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>The ®ISTRAR; includes 'vcard-temp:x:update' in its registry of protocol namespaces (see &NAMESPACES;).</p>
|
|
</section2>
|
|
</section1>
|
|
<section1 topic='XML Schema' anchor='schema'>
|
|
<code><![CDATA[
|
|
<?xml version='1.0' encoding='UTF-8'?>
|
|
|
|
<xs:schema
|
|
xmlns:xs='http://www.w3.org/2001/XMLSchema'
|
|
targetNamespace='vcard-temp:x:update'
|
|
xmlns='vcard-temp:x:update'
|
|
elementFormDefault='qualified'>
|
|
|
|
<xs:annotation>
|
|
<xs:documentation>
|
|
The protocol documented by this schema is defined in
|
|
XEP-0153: http://www.xmpp.org/extensions/xep-0153.html
|
|
</xs:documentation>
|
|
</xs:annotation>
|
|
|
|
<xs:element name='x'>
|
|
<xs:complexType>
|
|
<xs:sequence>
|
|
<xs:element name='photo' minOccurs='0' type='xs:base64Binary'/>
|
|
</xs:sequence>
|
|
</xs:complexType>
|
|
</xs:element>
|
|
|
|
</xs:schema>
|
|
]]></code>
|
|
</section1>
|
|
<section1 topic='Acknowledgements' anchor='ack'>
|
|
<p>The author wishes to thank the helpful developers who have implemented this protocol and provided feedback regarding its documentation.</p>
|
|
</section1>
|
|
</xep>
|