Unfortunately this has been engineered on top of msn protocol because it was the only one requiring it (and supported?) so it's kind of specific to this usage
However, you can see in papylib/Worker.py:
shortcut, hash_ = emotes.insert_resized((short, msnobj._data),
filename)
path = os.path.join(emotes.path, hash_)
received[short] = path
self.session.p2p_finished(account, 'emoticon', msnobj._creator,
shortcut, path)
where creator is the sending buddy's email, shortcut is a shortcut for the emoticon (like :) is for smiley face) and path is the path where the image is cached
The output extensions will automatically get those p2p_finished events with 'emoticon' as type and handle them accordingly with their extra arguments:
$ grep -ri "'emoticon'" *
e3/papylib/Worker.py: self.session.p2p_finished(account, 'emoticon', msnobj._creator,
gui/gtkui/TextBox.py: if _type == 'emoticon':
gui/gtkui/AdiumTextBox.py: if _type == 'emoticon':
gui/qt4ui/widgets/AdiumChatOutput.py: if _type == 'emoticon':
I think you can easily reuse this facility to show whatever you want to, see how i'd do it for AdiumTextBox.py:
def update_p2p(self, account, _type, *what):
''' new p2p data has been received (custom emoticons) '''
if _type == 'emoticon':
_creator, _friendly, path = what
_id = base64.b64encode(_creator+xml.sax.saxutils.unescape(_friendly)) #see gui/base/MarkupParser.py
mystr = "var now=new Date();var x=document.images;for(var i=0;i<x.length;i++){if(x[i].name=='%s'){x[i].src='%s?'+now.getTime();}}" % (_id, path)
self.view.execute_script(mystr)
elif _type == 'picture':
new, expanded, arguments, tuple = what
_id = base64.b64encode(_creator+xml.sax.saxutils.unescape(_friendly)) #see gui/base/MarkupParser.py
mystr = "var now=new Date();var x=document.images;for(var
i=0;i<x.length;i++){if(x[i].name=='%s'){x[i].src='%s?'+now.getTime();}}"
% (_id, path)
self.view.execute_script(mystr)
the _id thing is just some data we create using buddy's email+emoticon's friendly name so if you have 10 emoticons in the same page with the same sender and shortcut they will all get updated by the subsequent javascript hack using that as an _id for distinguish them.
At the end of the day, you just need to:
1) implement the picture receiving function in your library
2) receive the picture and save it in emesene's cache
3) call the p2p_finished action with the arguments you'll need in the ui (e.g. new 'picture' type and some other stuff..)
4) handle the new 'picture' type in the output widgets as you please