2 SleekXMPP: The Sleek XMPP Library
3 Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of SleekXMPP.
6 See the file LICENSE for copying permission.
9 from __future__
import unicode_literals
11 from sleekxmpp
.xmlstream
import ElementBase
, register_stanza_plugin
14 class AMP(ElementBase
):
15 namespace
= 'http://jabber.org/protocol/amp'
18 interfaces
= set(['from', 'to', 'status', 'per_hop'])
21 return JID(self
._get
_attr
('from'))
23 def set_from(self
, value
):
24 return self
._set
_attr
('from', str(value
))
27 return JID(self
._get
_attr
('from'))
29 def set_to(self
, value
):
30 return self
._set
_attr
('to', str(value
))
32 def get_per_hop(self
):
33 return self
._get
_attr
('per-hop') == 'true'
35 def set_per_hop(self
, value
):
37 return self
._set
_attr
('per-hop', 'true')
39 return self
._del
_attr
('per-hop')
41 def del_per_hop(self
):
42 return self
._del
_attr
('per-hop')
44 def add_rule(self
, action
, condition
, value
):
45 rule
= Rule(parent
=self
)
46 rule
['action'] = action
47 rule
['condition'] = condition
51 class Rule(ElementBase
):
52 namespace
= 'http://jabber.org/protocol/amp'
55 plugin_multi_attrib
= 'rules'
56 interfaces
= set(['action', 'condition', 'value'])
59 class InvalidRules(ElementBase
):
60 namespace
= 'http://jabber.org/protocol/amp'
61 name
= 'invalid-rules'
62 plugin_attrib
= 'invalid_rules'
65 class UnsupportedConditions(ElementBase
):
66 namespace
= 'http://jabber.org/protocol/amp'
67 name
= 'unsupported-conditions'
68 plugin_attrib
= 'unsupported_conditions'
71 class UnsupportedActions(ElementBase
):
72 namespace
= 'http://jabber.org/protocol/amp'
73 name
= 'unsupported-actions'
74 plugin_attrib
= 'unsupported_actions'
77 class FailedRule(Rule
):
78 namespace
= 'http://jabber.org/protocol/amp#errors'
81 class FailedRules(ElementBase
):
82 namespace
= 'http://jabber.org/protocol/amp#errors'
84 plugin_attrib
= 'failed_rules'
87 class AMPFeature(ElementBase
):
88 namespace
= 'http://jabber.org/features/amp'
92 register_stanza_plugin(AMP
, Rule
, iterable
=True)
93 register_stanza_plugin(InvalidRules
, Rule
, iterable
=True)
94 register_stanza_plugin(UnsupportedConditions
, Rule
, iterable
=True)
95 register_stanza_plugin(UnsupportedActions
, Rule
, iterable
=True)
96 register_stanza_plugin(FailedRules
, FailedRule
, iterable
=True)