Mercurial > libervia-backend
annotate src/plugins/plugin_xep_0280.py @ 2126:2f264f3df280
core (menus): improvments:
- use the new convention for bridge names (getMenus ==> menusGet, etc.)
- menu now use canonical path, which is the untranslated path with each element stripped and lowercase, it must be unique by menu type
- added menuLaunch method to manually launch a menu like an action, canonical path is used instead of id
- added SECURITY_LIMIT_MAX constant
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Jan 2017 20:29:48 +0100 |
parents | ad88808591ef |
children | 7de291c3cd0c |
rev | line source |
---|---|
2099
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # SAT plugin for managing xep-0280 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 from sat.core.i18n import _, D_ |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 from sat.core.log import getLogger |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 log = getLogger(__name__) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from sat.core import exceptions |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from sat.core.constants import Const as C |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from sat.core.xmpp import SatMessageProtocol |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from twisted.words.protocols.jabber.error import StanzaError |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from twisted.internet import defer |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from wokkel import disco, iwokkel |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 from zope.interface import implements |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 try: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from twisted.words.protocols.xmlstream import XMPPHandler |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 except ImportError: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 from wokkel.subprotocols import XMPPHandler |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 PARAM_CATEGORY = "Misc" |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 PARAM_NAME = "carbon" |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 PARAM_LABEL = D_(u"Message carbons") |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 NS_CARBONS = 'urn:xmpp:carbons:2' |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 PLUGIN_INFO = { |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 "name": "XEP-0280 Plugin", |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 "import_name": "XEP-0280", |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 "type": "XEP", |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 "protocols": ["XEP-0280"], |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 "dependencies": [], |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 "main": "XEP_0280", |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 "handler": "yes", |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 "description": _("""Implementation of Message Carbons""") |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 } |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 class XEP_0280(object): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 # TODO: param is only checked at profile connection |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 # activate carbons on param change even after profile connection |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 # TODO: chat state notifications are not handled yet (and potentially other XEPs?) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 params = """ |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 <params> |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 <individual> |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 <category name="{category_name}" label="{category_label}"> |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 <param name="{param_name}" label="{param_label}" value="true" type="bool" security="0" /> |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 </category> |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 </individual> |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 </params> |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 """.format( |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 category_name = PARAM_CATEGORY, |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 category_label = D_(PARAM_CATEGORY), |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 param_name = PARAM_NAME, |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 param_label = PARAM_LABEL, |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 ) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 def __init__(self, host): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 log.info(_("Plugin XEP_0280 initialization")) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 self.host = host |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 host.memory.updateParams(self.params) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 host.trigger.add("MessageReceived", self.messageReceivedTrigger, priority=1000) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 def getHandler(self, profile): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 return XEP_0280_handler() |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 @defer.inlineCallbacks |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 def profileConnected(self, profile): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 """activate message carbons on connection if possible and activated in config""" |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 client = self.host.getClient(profile) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 activate = self.host.memory.getParamA(PARAM_NAME, PARAM_CATEGORY, profile_key=profile) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 if not activate: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 log.info(_(u"Not activating message carbons as requested in params")) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 return |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 try: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 yield self.host.checkFeatures((NS_CARBONS,), profile=profile) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 except exceptions.FeatureNotFound: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 log.warning(_(u"server doesn't handle message carbons")) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 else: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 log.info(_(u"message carbons available, enabling it")) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 iq_elt = client.IQ() |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 iq_elt.addElement((NS_CARBONS, 'enable')) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 try: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 yield iq_elt.send() |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 except StanzaError as e: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 log.warning(u"Can't activate message carbons: {}".format(e)) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 else: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 log.info(_(u"message carbons activated")) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 def messageReceivedTrigger(self, client, message_elt, post_treat): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 """get message and handle it if carbons namespace is present""" |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 carbons_elt = None |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 for e in message_elt.elements(): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 if e.uri == NS_CARBONS: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 carbons_elt = e |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 break |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 if carbons_elt is None: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 # this is not a message carbons, |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 # we continue normal behaviour |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 return True |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 if message_elt['from'] != client.jid.userhost(): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 log.warning(u"The message carbon received is not from our server, hack attempt?\n{xml}".format( |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 xml = message_elt.toXml(), |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 )) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 return |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 forwarded_elt = next(carbons_elt.elements(C.NS_FORWARD, 'forwarded')) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 cc_message_elt = next(forwarded_elt.elements(C.NS_CLIENT, 'message')) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 if carbons_elt.name == 'received': |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 # on receive we replace the wrapping message with the CCed one |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 # and continue the normal behaviour |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 message_elt['from'] = cc_message_elt['from'] |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 del message_elt.children[:] |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 for c in cc_message_elt.children: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 message_elt.addChild(c) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 return True |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 elif carbons_elt.name == 'sent': |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 # on send we parse the message and just add it to history |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 # and send it to frontends (without normal sending treatments) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 mess_data = SatMessageProtocol.parseMessage(cc_message_elt, client) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 if not mess_data['message'] and not mess_data['subject']: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 return False |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 self.host.messageAddToHistory(mess_data, client) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 self.host.messageSendToBridge(mess_data, client) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 else: |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 log.warning(u"invalid message carbons received:\n{xml}".format( |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 xml = message_elt.toXml())) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 return False |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 class XEP_0280_handler(XMPPHandler): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 implements(iwokkel.IDisco) |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 return [disco.DiscoFeature(NS_CARBONS)] |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 def getDiscoItems(self, requestor, target, nodeIdentifier=''): |
ad88808591ef
plugin XEP-0280: Message Carbons first draft
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 return [] |