Custom smilies without shortcuts
ml at update.uu.se
Sun Sep 7 15:03:05 EDT 2008
ons 2008-09-03 klockan 20:22 -0600 skrev Peter Saint-Andre:
> Marcus Lundblad wrote:
> > The way it works currently is that the user will have assigned a number
> > of "shortcuts" to various emoticons.
> Are these assigned per-user? For example, can you and I assign different
> shortcuts to the same emoticon?
Yes. The user will assign shortcuts to their emoticons locally.
> > So when a message is sent and the receiver supports XHTML-IM and
> > XEP-0231 the occurances of these shortcuts are substituted in the html
> > body with an <img/> tag where the "alt" attribute is set to that
> > shortcut. The src will be a cid-based URI according to XEP-0231. Now the
> > receiver would ask for the data if it hasn't already cached it.
> OK, so the receiving client essentially does a search and replace on the
> message body, replace the textual shortcut with the image data.
Yes, the receiver would search and replace all <img/> tags that has a
src of the form "cid:....".
So if the message doesn't contain XHTML-IM content these tags will not
be included. And in the "ordinary" <body/> (directly under the
<message/>) the text shortcut is placed as normal text.
So only a client aware of XHTML-IM would know about them.
So lets say I have assigned :=) to some emoticon and send a message
containing the string
"Hi, this is something cool :=)"
The resulting stanza would look like:
<body>Hi, this is something cool :=)</body>
<body>Hi, this is something cool <img alt=':=)' src='cid:sha1
+hash at bob.xmpp.org'/></body>
(plus namespaces and so on...)
Now if the receiver understands XHTML-IM and is set to fetch emoticons
using this protocol, it would look at each <img/> that has a src of the
form "cid:..." and request the data if it isn't cached as in XEP-0231.
In the implementation I have written, I would only include such
emoticons if the receiver supports "urn:xmpp:bob"
Otherwise the text will be sent as is. This way a client that doesn't
support it will still see the textual representation of the emoticon
(which hopefully will still give it some meaning... :))
> > What Jean La was wondering would be if it would be possible to insert
> > emoticons without assigning a smiley shortcut. This would ofcourse be
> > possible using the specification of the XEPs. I'm not sure wether the
> > "alt" attributes on <img/> is required in XEP-0071, but in that case it
> > would be possible to auto-generate that string. But the way it will work
> > in libpurple is probably that it will always be a shortcut associated
> > with each custom emoticon.
> Support for the 'alt' attribute is required on the receiving end
> according to XEP-0071, but the spec doesn't say whether the sender must
> always include that attribute.
Actually I have handled this case by assuming the "alt" is the same as
the cid part of the src.
In the UI, if the user hovers over an emoticon it will show this
"shortcut", so in that case it would show the cid value.
Also the receiver can add the emoticon to his own collection by using a
context menu. In this case the shortcut field will be pre-filled with
the value set by the sender, but this can be changed.
> > Presently I only cache received data by CID in memory for the running
> > instance. Further on, implementing a persistent data cache would
> > probably be a good idea. Since we now have the hash algorithm and hash
> > in the CID it might make sense to implement a cache based on hash
> > values. This might make it possible to share cached emoticons between
> > the protocols that implement similar featurs.
> Yes that would be good.
> > So for this use-case the current specification of XEP-0231 in
> > conjunction with XHTML-IM works nicely.
> > The implementation seems to work quite nice, I've even done some interop
> > testing with the Jabbim developers.
> > I haven't looked that much at XEP-0038. But I think I remember there
> > being a discussion about a common format for distributing smiley themes
> > among various IM clients. The thing that makes it a bit more complicated
> > is that libpurple-based clients (and Kopete and others) supports
> > multiple protocols. The proprietary protocols tend to have a fixed set
> > of smiley codes used by their respective "official" client. Maybe
> > something based on XEP-0038 might make sense for this.
> By "smiley code" do you mean the shortcuts or the images? Either way I
> think we can handle common shortcuts and images by convention (e.g., an
> opens-source project that everyone can re-use) rather than spec it out
> in a document -- but I'm happy to help document it if that would be useful.
I meant the shortcut string that "triggers" the emoticon to be sent.
Maybe a common recommended set of standard emoticons might make sense
for graphical clients.
But I guess it would merly be a recommendation that clients could
> > By the way, XEP-0231 mentions the use for XHTML-IM. In the old
> > specification there was a use-case for providing a preview in a file
> > transfer. Would this be added to the new Jingle file transfer XEP,
> > f.ex.?
> Yes. Or XEP-0096 or something. We'll find the right place for it. :)
More information about the Devel