annotate src/plugins/plugin_xep_0077.py @ 776:f89173f44850

frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
author Goffi <goffi@goffi.org>
date Fri, 03 Jan 2014 21:25:07 +0100
parents bfabeedbf32e
children be4c5e24dab9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
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
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 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 _
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from logging import debug, info, error
554
caad23285a38 plugin XEP-0077: misc fixes
Goffi <goffi@goffi.org>
parents: 538
diff changeset
22 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
23 from twisted.words.protocols.jabber.xmlstream import IQ
761
2f8d72226bc0 core (xml_tools): dataForm*2XML renamed to dataForm*2XMLUI and now return XMLUI instead of raw XML + submit_id is managed, and session_id is returned if present
Goffi <goffi@goffi.org>
parents: 630
diff changeset
24 from sat.tools.xml_tools import dataForm2XMLUI
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25
33
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 30
diff changeset
26 from wokkel import data_form
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 30
diff changeset
27
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 NS_REG = 'jabber:iq:register'
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 PLUGIN_INFO = {
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
31 "name": "XEP 0077 Plugin",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
32 "import_name": "XEP-0077",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
33 "type": "XEP",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
34 "protocols": ["XEP-0077"],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
35 "dependencies": [],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
36 "main": "XEP_0077",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
37 "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
38 }
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
40
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
41 class XEP_0077(object):
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
42
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 def __init__(self, host):
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 64
diff changeset
44 info(_("Plugin XEP_0077 initialization"))
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self.host = host
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
46 self.triggers = {} # used by other protocol (e.g. XEP-0100) to finish registration. key = target_jid
372
f964dcec1611 core: plugins refactored according to bridge + updatedValue now use profile
Goffi <goffi@goffi.org>
parents: 291
diff changeset
47 host.bridge.addMethod("in_band_register", ".plugin", in_sign='ss', out_sign='s', method=self.in_band_register)
468
c97640c90a94 D-Bus Bridge: use inspection to name attribute + fix asynchronous calls for dynamically added method, it now use deferred return value instead of callback/errback attributes
Goffi <goffi@goffi.org>
parents: 459
diff changeset
48 host.bridge.addMethod("in_band_submit", ".plugin", in_sign='ssa(ss)s', out_sign='s', method=self.in_band_submit)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
49
169
06985b6ad23a SàT: plugin 0077 & 0100: fixed profile management
Goffi <goffi@goffi.org>
parents: 103
diff changeset
50 def addTrigger(self, target, cb, profile):
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
51 """Add a callback which is called when registration to target is successful"""
169
06985b6ad23a SàT: plugin 0077 & 0100: fixed profile management
Goffi <goffi@goffi.org>
parents: 103
diff changeset
52 self.triggers[target] = (cb, profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
53
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
54 def reg_ok(self, answer, profile):
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:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
57 x_elem = filter(lambda x: x.name == "x", answer.firstChildElement().elements())[0] # We only want the "x" element (data form)
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
58 except IndexError:
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 64
diff changeset
59 info(_("No data form found"))
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
60 #TODO: manage registration without data form
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
61 answer_data = {"reason": "unmanaged", "message": _("This gateway can't be managed by SàT, sorry :(")}
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
62 answer_type = "ERROR"
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
63 self.host.bridge.actionResult(answer_type, answer['id'], answer_data, profile)
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
64 return
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
65
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
66 form = data_form.Form.fromElement(x_elem)
761
2f8d72226bc0 core (xml_tools): dataForm*2XML renamed to dataForm*2XMLUI and now return XMLUI instead of raw XML + submit_id is managed, and session_id is returned if present
Goffi <goffi@goffi.org>
parents: 630
diff changeset
67 xml_data = dataForm2XMLUI(form, "").toXml()
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
68 self.host.bridge.actionResult("XMLUI", answer['id'], {"target": answer["from"], "type": "registration", "xml": xml_data}, profile)
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
69
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
70 def reg_err(self, failure, profile):
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
71 """Called when something is wrong with registration"""
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
72 info(_("Registration failure: %s") % str(failure.value))
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
73 answer_data = {}
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
74 answer_data['reason'] = 'unknown'
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
75 answer_data = {"message": "%s [code: %s]" % (failure.value.condition, unicode(failure.value))}
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
76 answer_type = "ERROR"
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
77 self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data, profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
78
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
79 def unregistrationAnswer(self, answer, profile):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
80 debug(_("registration answer: %s") % answer.toXml())
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
81 answer_type = "SUCCESS"
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
82 answer_data = {"message": _("Your are now unregistred")}
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
83 self.host.bridge.actionResult(answer_type, answer['id'], answer_data, profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
84
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
85 def unregistrationFailure(self, failure, profile):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
86 info(_("Unregistration failure: %s") % str(failure.value))
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
87 answer_type = "ERROR"
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
88 answer_data = {}
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
89 answer_data['reason'] = 'unknown'
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
90 answer_data = {"message": _("Unregistration failed: %s") % failure.value.condition}
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
91 self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data, profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
92
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
93 def registrationAnswer(self, answer, profile):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
94 debug(_("registration answer: %s") % answer.toXml())
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
95 answer_type = "SUCCESS"
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
96 answer_data = {"message": _("Registration successfull")}
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
97 self.host.bridge.actionResult(answer_type, answer['id'], answer_data, profile)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
98 if answer["from"] in self.triggers:
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
99 callback, profile = self.triggers[answer["from"]]
169
06985b6ad23a SàT: plugin 0077 & 0100: fixed profile management
Goffi <goffi@goffi.org>
parents: 103
diff changeset
100 callback(answer["from"], profile)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
101 del self.triggers[answer["from"]]
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
102
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
103 def registrationFailure(self, failure, profile):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
104 info(_("Registration failure: %s") % str(failure.value))
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
105 print failure.value.stanza.toXml()
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
106 answer_type = "ERROR"
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
107 answer_data = {}
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
108 if failure.value.condition == 'conflict':
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
109 answer_data['reason'] = 'conflict'
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
110 answer_data = {"message": _("Username already exists, please choose an other one")}
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
111 else:
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
112 answer_data['reason'] = 'unknown'
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
113 answer_data = {"message": _("Registration failed")}
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
114 self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data, profile)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
115 if failure.value.stanza["from"] in self.triggers:
554
caad23285a38 plugin XEP-0077: misc fixes
Goffi <goffi@goffi.org>
parents: 538
diff changeset
116 del self.triggers[failure.value.stanza["from"]]
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
117
169
06985b6ad23a SàT: plugin 0077 & 0100: fixed profile management
Goffi <goffi@goffi.org>
parents: 103
diff changeset
118 def in_band_submit(self, action, target, fields, profile):
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
119 """Submit a form for registration, using data_form"""
169
06985b6ad23a SàT: plugin 0077 & 0100: fixed profile management
Goffi <goffi@goffi.org>
parents: 103
diff changeset
120 id, deferred = self.host.submitForm(action, target, fields, profile)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
121 if action == 'CANCEL':
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
122 deferred.addCallbacks(self.unregistrationAnswer, self.unregistrationFailure, callbackArgs=[profile], errbackArgs=[profile])
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
123 else:
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
124 deferred.addCallbacks(self.registrationAnswer, self.registrationFailure, callbackArgs=[profile], errbackArgs=[profile])
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
125 return id
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
126
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
127 def in_band_register(self, target, profile_key='@DEFAULT@'):
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
128 """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
129 client = self.host.getClient(profile_key)
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 480
diff changeset
130 if not client:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
131 error(_('Asking for an non-existant or not connected profile'))
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
132 return ""
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
133 to_jid = jid.JID(target)
69
86f1f7f6d332 i18n first draft
Goffi <goffi@goffi.org>
parents: 64
diff changeset
134 debug(_("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
135 reg_request = IQ(client.xmlstream, 'get')
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
136 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
137 reg_request["to"] = to_jid.full()
554
caad23285a38 plugin XEP-0077: misc fixes
Goffi <goffi@goffi.org>
parents: 538
diff changeset
138 reg_request.addElement('query', NS_REG)
caad23285a38 plugin XEP-0077: misc fixes
Goffi <goffi@goffi.org>
parents: 538
diff changeset
139 reg_request.send(to_jid.full()).addCallbacks(self.reg_ok, self.reg_err, callbackArgs=[client.profile], errbackArgs=[client.profile])
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
140 return reg_request["id"]