Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0280.py @ 2133:7de291c3cd0c
plugin XEP-0280: new setPrivate method to tell server not to carbon copy it.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 05 Feb 2017 14:55:21 +0100 |
parents | ad88808591ef |
children | 1d3f73e065e1 |
comparison
equal
deleted
inserted
replaced
2132:c0577837680a | 2133:7de291c3cd0c |
---|---|
37 PARAM_NAME = "carbon" | 37 PARAM_NAME = "carbon" |
38 PARAM_LABEL = D_(u"Message carbons") | 38 PARAM_LABEL = D_(u"Message carbons") |
39 NS_CARBONS = 'urn:xmpp:carbons:2' | 39 NS_CARBONS = 'urn:xmpp:carbons:2' |
40 | 40 |
41 PLUGIN_INFO = { | 41 PLUGIN_INFO = { |
42 "name": "XEP-0280 Plugin", | 42 "name": u"XEP-0280 Plugin", |
43 "import_name": "XEP-0280", | 43 "import_name": u"XEP-0280", |
44 "type": "XEP", | 44 "type": u"XEP", |
45 "protocols": ["XEP-0280"], | 45 "protocols": [u"XEP-0280"], |
46 "dependencies": [], | 46 "dependencies": [], |
47 "main": "XEP_0280", | 47 "main": u"XEP_0280", |
48 "handler": "yes", | 48 "handler": u"yes", |
49 "description": _("""Implementation of Message Carbons""") | 49 "description": D_(u"""Implementation of Message Carbons""") |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 class XEP_0280(object): | 53 class XEP_0280(object): |
54 # TODO: param is only checked at profile connection | 54 # TODO: param is only checked at profile connection |
76 host.memory.updateParams(self.params) | 76 host.memory.updateParams(self.params) |
77 host.trigger.add("MessageReceived", self.messageReceivedTrigger, priority=1000) | 77 host.trigger.add("MessageReceived", self.messageReceivedTrigger, priority=1000) |
78 | 78 |
79 def getHandler(self, profile): | 79 def getHandler(self, profile): |
80 return XEP_0280_handler() | 80 return XEP_0280_handler() |
81 | |
82 def setPrivate(self, message_elt): | |
83 """Add a <private/> element to a message | |
84 | |
85 this method is intented to be called on final domish.Element by other plugins | |
86 (in particular end 2 end encryption plugins) | |
87 @param message_elt(domish.Element): <message> stanza | |
88 """ | |
89 if message_elt.name != u'message': | |
90 log.error(u"addPrivateElt must be used with <message> stanzas") | |
91 return | |
92 message_elt.addElement((NS_CARBONS, u'private')) | |
81 | 93 |
82 @defer.inlineCallbacks | 94 @defer.inlineCallbacks |
83 def profileConnected(self, profile): | 95 def profileConnected(self, profile): |
84 """activate message carbons on connection if possible and activated in config""" | 96 """activate message carbons on connection if possible and activated in config""" |
85 client = self.host.getClient(profile) | 97 client = self.host.getClient(profile) |