2 SleekXMPP: The Sleek XMPP Library
3 Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of SleekXMPP.
6 See the file LICENSE for copying permission.
9 from base64
import b64encode
, b64decode
11 from sleekxmpp
.util
import bytes
12 from sleekxmpp
.xmlstream
import ET
, ElementBase
, register_stanza_plugin
15 class Data(ElementBase
):
17 namespace
= 'urn:xmpp:avatar:data'
18 plugin_attrib
= 'avatar_data'
19 interfaces
= set(['value'])
23 return b64decode(bytes(self
.xml
.text
))
26 def set_value(self
, value
):
28 self
.xml
.text
= b64encode(bytes(value
))
36 class MetaData(ElementBase
):
38 namespace
= 'urn:xmpp:avatar:metadata'
39 plugin_attrib
= 'avatar_metadata'
42 def add_info(self
, id, itype
, ibytes
, height
=None, width
=None, url
=None):
44 info
.values
= {'id': id,
46 'bytes': '%s' % ibytes
,
52 def add_pointer(self
, xml
):
53 if not isinstance(xml
, Pointer
):
61 class Info(ElementBase
):
63 namespace
= 'urn:xmpp:avatar:metadata'
64 plugin_attrib
= 'info'
65 plugin_multi_attrib
= 'items'
66 interfaces
= set(['bytes', 'height', 'id', 'type', 'url', 'width'])
69 class Pointer(ElementBase
):
71 namespace
= 'urn:xmpp:avatar:metadata'
72 plugin_attrib
= 'pointer'
73 plugin_multi_attrib
= 'pointers'
77 register_stanza_plugin(MetaData
, Info
, iterable
=True)
78 register_stanza_plugin(MetaData
, Pointer
, iterable
=True)