Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_utils.py @ 510:886754295efe
quick frontend, primitivus, wix: MUC private messages management
/!\ not fully finished, backend part is not done yet /!\
- as resources are discarded to manage chat windows lists, a pretty dirty hack is done to work around this:
full jid is escaped using a prefix (it becomes invalid and resource is preserved).
- new quick_utils module, with helper methods. escapePrivate and unescapePrivate implementations
- MUC private messages are not managed in Wix yet
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 11 Oct 2012 00:48:35 +0200 |
parents | |
children | 3eeb6c865e4d |
comparison
equal
deleted
inserted
replaced
509:64ff046dc201 | 510:886754295efe |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 Primitivus: a SAT frontend | |
6 Copyright (C) 2009, 2010, 2011, 2012 Jérôme Poisson (goffi@goffi.org) | |
7 | |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Affero General Public License | |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 """ | |
21 | |
22 from sat.tools.jid import JID | |
23 | |
24 def escapePrivate(ori_jid): | |
25 """Escape a private jid""" | |
26 return JID(const_PRIVATE_PREFIX + ori_jid.short + '@' + ori_jid.resource) | |
27 | |
28 def unescapePrivate(escaped_jid): | |
29 if not escaped_jid.startswith(const_PRIVATE_PREFIX): | |
30 return escaped_jid | |
31 escaped_split = tuple(escaped_jid[len(const_PRIVATE_PREFIX):].split('@')) | |
32 assert(len(escaped_split) == 3) | |
33 return JID("%s@%s/%s" % escaped_split) |