Mercurial > libervia-backend
annotate twisted/plugins/sat_plugin.py @ 3060:730bbed77a89
plugin XEP-0045: join / MAM history improvements:
- fixed use of history_d deferred so MAM history is stored in database as soon as possible
and in right order
- get MAM history with pages of 20 messages instead of 100
- if a message can't be parsed, an error message is logged (with a dump of the stanza),
and the message is ignored, avoiding a crash and the impossibility the join the room at
all
- a new `mucRoomPrepareJoin` signal, containing room jid and profile, is sent when a room
joining is started, this allow better UX as the frontend can show the room immediately,
and lock it with a waiting message until it is fully available. The `mucRoomJoined` is
still sent when the room is fully joined/avaiable, meaning that the frontend can unlock
it and let the user interact with it
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 18 Oct 2019 14:45:07 +0200 |
parents | 8b36e5c3f28f |
children | 2180b0f5c1cd |
rev | line source |
---|---|
3040 | 1 #!/usr/bin/env python3 |
0 | 2 # -*- coding: utf-8 -*- |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
4 # SAT: a jabber client |
2483 | 5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
572
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
1014
e40d9858cb83
core: if in debug mode and ipdb is present, use ipdb instead of pdb
Goffi <goffi@goffi.org>
parents:
1010
diff
changeset
|
20 |
3028 | 21 from zope.interface import implementer |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
22 from twisted.python import usage |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
23 from twisted.plugin import IPlugin |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
24 from twisted.application.service import IServiceMaker |
0 | 25 |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
26 # XXX: We need to configure logs before any log method is used, so here is the best place. |
1010
73a0b7f94674
primitivus: use of new logging system:
Goffi <goffi@goffi.org>
parents:
994
diff
changeset
|
27 from sat.core.constants import Const as C |
1130 | 28 from sat.core.i18n import _ |
29 | |
991
05e02f8b7eb4
core: logging refactoring, first step:
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
30 |
1130 | 31 def initialise(options): |
32 """Method to initialise global modules""" | |
33 # XXX: We need to configure logs before any log method is used, so here is the best place. | |
34 from sat.core import log_config | |
35 log_config.satConfigure(C.LOG_BACKEND_TWISTED, C, backend_data=options) | |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
36 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
37 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
38 class Options(usage.Options): |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
39 optParameters = [] |
101 | 40 |
994
652c01ca69b1
core (log): configuration and environment variables are now checked for log level and colors:
Goffi <goffi@goffi.org>
parents:
991
diff
changeset
|
41 |
3028 | 42 @implementer(IPlugin, IServiceMaker) |
43 class SatMaker: | |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
44 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
45 tapname = C.APP_NAME_FILE |
3028 | 46 description = _("%s XMPP client backend") % C.APP_NAME_FULL |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
47 options = Options |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
48 |
3053
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
49 def setDebugger(self): |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
50 from twisted.internet import defer |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
51 if defer.Deferred.debug: |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
52 # if we are in debug mode, we want to use ipdb instead of pdb |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
53 try: |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
54 import ipdb |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
55 import pdb |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
56 pdb.set_trace = ipdb.set_trace |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
57 pdb.post_mortem = ipdb.post_mortem |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
58 except ImportError: |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
59 pass |
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
60 |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
61 def makeService(self, options): |
2695
c5543fba97e8
core: fixed reactor crash by installing reactor only in makeService
Goffi <goffi@goffi.org>
parents:
2670
diff
changeset
|
62 from twisted.internet import gireactor |
c5543fba97e8
core: fixed reactor crash by installing reactor only in makeService
Goffi <goffi@goffi.org>
parents:
2670
diff
changeset
|
63 gireactor.install() |
3053
8b36e5c3f28f
misc: don't import memory in launch script:
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
64 self.setDebugger() |
1130 | 65 # XXX: SAT must be imported after log configuration, because it write stuff to logs |
66 initialise(options.parent) | |
67 from sat.core.sat_main import SAT | |
1122
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
68 return SAT() |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
69 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
70 |
9ae01ccf89c1
core: sat bakcend is now a twisted plugin (no more .tac file)
Goffi <goffi@goffi.org>
parents:
1021
diff
changeset
|
71 serviceMaker = SatMaker() |