2 SleekXMPP: The Sleek XMPP Library
3 Copyright (C) 2010 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of SleekXMPP.
6 See the file LICENSE for copying permission.
12 from sleekxmpp
.plugins
.xep_0030
import StaticDisco
15 log
= logging
.getLogger(__name__
)
18 class StaticExtendedDisco(object):
21 Extend the default StaticDisco implementation to provide
22 support for extended identity information.
25 def __init__(self
, static
):
27 Augment the default XEP-0030 static handler object.
30 static -- The default static XEP-0030 handler object.
34 def set_extended_info(self
, jid
, node
, ifrom
, data
):
36 Replace the extended identity data for a JID/node combination.
38 The data parameter may provide:
39 data -- Either a single data form, or a list of data forms.
41 with self
.static
.lock
:
42 self
.del_extended_info(jid
, node
, ifrom
, data
)
43 self
.add_extended_info(jid
, node
, ifrom
, data
)
45 def add_extended_info(self
, jid
, node
, ifrom
, data
):
47 Add additional extended identity data for a JID/node combination.
49 The data parameter may provide:
50 data -- Either a single data form, or a list of data forms.
52 with self
.static
.lock
:
53 self
.static
.add_node(jid
, node
)
55 forms
= data
.get('data', [])
56 if not isinstance(forms
, list):
59 info
= self
.static
.get_node(jid
, node
)['info']
63 def del_extended_info(self
, jid
, node
, ifrom
, data
):
65 Replace the extended identity data for a JID/node combination.
67 The data parameter is not used.
69 with self
.static
.lock
:
70 if self
.static
.node_exists(jid
, node
):
71 info
= self
.static
.get_node(jid
, node
)['info']
72 for form
in info
['substanza']:
73 info
.xml
.remove(form
.xml
)