Mercurial > libervia-backend
comparison libervia/backend/core/core_types.py @ 4071:4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 11:49:51 +0200 |
parents | sat/core/core_types.py@3900626bc100 |
children | c38c33a44171 |
comparison
equal
deleted
inserted
replaced
4070:d10748475025 | 4071:4b842c1fb686 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 # Libervia types | |
4 # Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 from collections import namedtuple | |
20 from typing import Dict, Callable, Optional | |
21 from typing_extensions import TypedDict | |
22 | |
23 from twisted.words.protocols.jabber import jid as t_jid | |
24 from twisted.words.protocols.jabber import xmlstream | |
25 from twisted.words.xish import domish | |
26 | |
27 | |
28 class SatXMPPEntity: | |
29 | |
30 profile: str | |
31 jid: t_jid.JID | |
32 is_component: bool | |
33 server_jid: t_jid.JID | |
34 IQ: Callable[[Optional[str], Optional[int]], xmlstream.IQ] | |
35 | |
36 EncryptionPlugin = namedtuple("EncryptionPlugin", ("instance", | |
37 "name", | |
38 "namespace", | |
39 "priority", | |
40 "directed")) | |
41 | |
42 | |
43 class EncryptionSession(TypedDict): | |
44 plugin: EncryptionPlugin | |
45 | |
46 | |
47 # Incomplete types built through observation rather than code inspection. | |
48 MessageDataExtra = TypedDict( | |
49 "MessageDataExtra", | |
50 { "encrypted": bool, "origin_id": str }, | |
51 total=False | |
52 ) | |
53 | |
54 | |
55 MessageData = TypedDict("MessageData", { | |
56 "from": t_jid.JID, | |
57 "to": t_jid.JID, | |
58 "uid": str, | |
59 "message": Dict[str, str], | |
60 "subject": Dict[str, str], | |
61 "type": str, | |
62 "timestamp": float, | |
63 "extra": MessageDataExtra, | |
64 "ENCRYPTION": EncryptionSession, | |
65 "xml": domish.Element | |
66 }, total=False) |