Rename to slixmpp
[slixmpp.git] / slixmpp / plugins / xep_0027 / stanza.py
blobfd41caced9a28b1cbcaec6e0a0e495fe12a11837
1 """
2 Slixmpp: The Slick XMPP Library
3 Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of Slixmpp.
6 See the file LICENSE for copying permission.
7 """
9 from slixmpp.xmlstream import ElementBase
12 class Signed(ElementBase):
13 name = 'x'
14 namespace = 'jabber:x:signed'
15 plugin_attrib = 'signed'
16 interfaces = set(['signed'])
17 is_extension = True
19 def set_signed(self, value):
20 parent = self.parent()
21 xmpp = parent.stream
22 data = xmpp['xep_0027'].sign(value, parent['from'])
23 if data:
24 self.xml.text = data
25 else:
26 del parent['signed']
28 def get_signed(self):
29 return self.xml.text
32 class Encrypted(ElementBase):
33 name = 'x'
34 namespace = 'jabber:x:encrypted'
35 plugin_attrib = 'encrypted'
36 interfaces = set(['encrypted'])
37 is_extension = True
39 def set_encrypted(self, value):
40 parent = self.parent()
41 xmpp = parent.stream
42 data = xmpp['xep_0027'].encrypt(value, parent['to'])
43 if data:
44 self.xml.text = data
45 else:
46 del parent['encrypted']
48 def get_encrypted(self):
49 parent = self.parent()
50 xmpp = parent.stream
51 if self.xml.text:
52 return xmpp['xep_0027'].decrypt(self.xml.text, parent['to'])
53 return None