annotate src/plugins/plugin_xep_0077.py @ 1955:633b5c21aefd

backend, frontend: messages refactoring (huge commit, not finished): /!\ database schema has been modified, do a backup before updating message have been refactored, here are the main changes: - languages are now handled - all messages have an uid (internal to SàT) - message updating is anticipated - subject is now first class - new naming scheme is used newMessage => messageNew, getHistory => historyGet, sendMessage => messageSend - minimal compatibility refactoring in quick_frontend/Primitivus, better refactoring should follow - threads handling - delayed messages are saved into history - info messages may also be saved in history (e.g. to keep track of people joining/leaving a room) - duplicate messages should be avoided - historyGet return messages in right order, no need to sort again - plugins have been updated to follow new features, some of them need to be reworked (e.g. OTR) - XEP-0203 (Delayed Delivery) is now fully handled in core, the plugin just handle disco and creation of a delay element - /!\ jp and Libervia are currently broken, as some features of Primitivus It has been put in one huge commit to avoid breaking messaging between changes. This is the main part of message refactoring, other commits will follow to take profit of the new features/behaviour.
author Goffi <goffi@goffi.org>
date Tue, 24 May 2016 22:11:04 +0200
parents 2daf7b4c6756
children 33c8c4973743
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1934
2daf7b4c6756 use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
1 #!/usr/bin/env python2
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
4 # SAT plugin for managing xep-0077
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org)
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
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: 594
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: 594
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: 594
diff changeset
10 # (at your option) any later version.
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
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: 594
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: 594
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: 594
diff changeset
15 # GNU Affero General Public License for more details.
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
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: 594
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 761
diff changeset
20 from sat.core.i18n import _
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 876
diff changeset
21 from sat.core.constants import Const as C
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
22 from sat.core import exceptions
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 941
diff changeset
23 from sat.core.log import getLogger
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 941
diff changeset
24 log = getLogger(__name__)
554
caad23285a38 plugin XEP-0077: misc fixes
Goffi <goffi@goffi.org>
parents: 538
diff changeset
25 from twisted.words.protocols.jabber import jid
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from twisted.words.protocols.jabber.xmlstream import IQ
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
27 from sat.tools import xml_tools
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
29 from wokkel import data_form, compat
33
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 30
diff changeset
30
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31 NS_REG = 'jabber:iq:register'
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33 PLUGIN_INFO = {
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
34 "name": "XEP 0077 Plugin",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
35 "import_name": "XEP-0077",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
36 "type": "XEP",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
37 "protocols": ["XEP-0077"],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
38 "dependencies": [],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
39 "main": "XEP_0077",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
40 "description": _("""Implementation of in-band registration""")
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41 }
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
42
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
43
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
44 class XEP_0077(object):
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
45
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46 def __init__(self, host):
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 941
diff changeset
47 log.info(_("Plugin XEP_0077 initialization"))
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.host = host
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
49 self.triggers = {} # used by other protocol (e.g. XEP-0100) to finish registration. key = target_jid
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
50 host.bridge.addMethod("inBandRegister", ".plugin", in_sign='ss', out_sign='s',
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
51 method=self._inBandRegister,
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
52 async=True)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
53
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
54 def _regOk(self, answer, client, post_treat_cb):
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55 """Called after the first get IQ"""
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
56 try:
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
57 query_elt = answer.elements(NS_REG, 'query').next()
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
58 except StopIteration:
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
59 raise exceptions.DataError("Can't find expected query element")
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
60
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
61 try:
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
62 x_elem = query_elt.elements(data_form.NS_X_DATA, 'x').next()
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
63 except StopIteration:
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
64 # XXX: it seems we have an old service which doesn't manage data forms
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 941
diff changeset
65 log.warning(_("Can't find data form"))
876
65bf1bc70f6b tools, plugin XEP-0077: small fixes
souliane <souliane@mailoo.org>
parents: 811
diff changeset
66 raise exceptions.DataError(_("This gateway can't be managed by SàT, sorry :("))
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
67
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
68 def submitForm(data, profile):
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
69 form_elt = xml_tools.XMLUIResultToElt(data)
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
70
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
71 iq_elt = compat.IQ(client.xmlstream, 'set')
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
72 iq_elt['id'] = answer['id']
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
73 iq_elt['to'] = answer['from']
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
74 query_elt = iq_elt.addElement("query", NS_REG)
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
75 query_elt.addChild(form_elt)
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
76 d = iq_elt.send()
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
77 d.addCallback(self._regSuccess, client, post_treat_cb)
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
78 d.addErrback(self._regFailure, client)
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
79 return d
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
80
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
81 form = data_form.Form.fromElement(x_elem)
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
82 submit_reg_id = self.host.registerCallback(submitForm, with_data=True, one_shot=True)
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
83 return xml_tools.dataForm2XMLUI(form, submit_reg_id)
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
84
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
85 def _regErr(self, failure, client):
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
86 """Called when something is wrong with registration"""
1409
3265a2639182 massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 1396
diff changeset
87 log.info(_("Registration failure: %s") % unicode(failure.value))
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
88 raise failure
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
89
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
90 def _regSuccess(self, answer, client, post_treat_cb):
1409
3265a2639182 massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 1396
diff changeset
91 log.debug(_(u"registration answer: %s") % answer.toXml())
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
92 if post_treat_cb is not None:
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
93 post_treat_cb(jid.JID(answer['from']), client.profile)
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
94 return {}
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
95
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
96 def _regFailure(self, failure, client):
1409
3265a2639182 massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 1396
diff changeset
97 log.info(_(u"Registration failure: %s") % unicode(failure.value))
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
98 if failure.value.condition == 'conflict':
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
99 raise exceptions.ConflictError( _("Username already exists, please choose an other one"))
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
100 raise failure
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
101
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 876
diff changeset
102 def _inBandRegister(self, to_jid_s, profile_key=C.PROF_KEY_NONE):
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
103 return self.inBandRegister, jid.JID(to_jid_s, profile_key)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
104
916
1a759096ccbd core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
Goffi <goffi@goffi.org>
parents: 876
diff changeset
105 def inBandRegister(self, to_jid, post_treat_cb=None, profile_key=C.PROF_KEY_NONE):
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106 """register to a target JID"""
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
107 client = self.host.getClient(profile_key)
1409
3265a2639182 massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 1396
diff changeset
108 log.debug(_(u"Asking registration for [%s]") % to_jid.full())
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
109 reg_request = IQ(client.xmlstream, 'get')
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
110 reg_request["from"] = client.jid.full()
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
111 reg_request["to"] = to_jid.full()
554
caad23285a38 plugin XEP-0077: misc fixes
Goffi <goffi@goffi.org>
parents: 538
diff changeset
112 reg_request.addElement('query', NS_REG)
807
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
113 d = reg_request.send(to_jid.full()).addCallbacks(self._regOk, self._regErr, callbackArgs=[client, post_treat_cb], errbackArgs=[client])
be4c5e24dab9 plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
Goffi <goffi@goffi.org>
parents: 771
diff changeset
114 return d