aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-11-18 16:55:36 +0100
committerfiaxh <git@lightrise.org>2019-11-18 17:02:59 +0100
commitfcce176b91f5136aac745cc3ab66afa632de8180 (patch)
tree630136d34cbdfe0a3055fc94655045ee7f2269bd /libdino/src/service
parent05561dd677b4098d1a618bcc3e01fc77c5ce19de (diff)
downloaddino-fcce176b91f5136aac745cc3ab66afa632de8180.tar.gz
dino-fcce176b91f5136aac745cc3ab66afa632de8180.zip
Open new connection to send filled-in registration form
fixes #644
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/registration.vala41
1 files changed, 38 insertions, 3 deletions
diff --git a/libdino/src/service/registration.vala b/libdino/src/service/registration.vala
index 4fcfdeba..20ea6063 100644
--- a/libdino/src/service/registration.vala
+++ b/libdino/src/service/registration.vala
@@ -104,7 +104,6 @@ public class Register : StreamInteractionModule, Object{
stream.add_module(new Xep.SrvRecordsTls.Module());
stream.add_module(new Xep.InBandRegistration.Module());
- Xep.InBandRegistration.Form? form = null;
SourceFunc callback = get_registration_form.callback;
stream.stream_negotiated.connect(() => {
@@ -125,14 +124,50 @@ public class Register : StreamInteractionModule, Object{
});
yield;
+
+ Xep.InBandRegistration.Form? form = null;
if (stream.negotiation_complete) {
form = yield stream.get_module(Xep.InBandRegistration.Module.IDENTITY).get_from_server(stream, jid);
}
+ try {
+ stream.disconnect();
+ } catch (Error e) {}
+
return form;
}
- public static async string submit_form(Jid jid, Xep.InBandRegistration.Form form) {
- return yield form.stream.get_module(Xep.InBandRegistration.Module.IDENTITY).submit_to_server(form.stream, jid, form);
+ public static async string? submit_form(Jid jid, Xep.InBandRegistration.Form form) {
+ XmppStream stream = new XmppStream();
+ stream.log = new XmppLog(jid.to_string(), Application.print_xmpp);
+ stream.add_module(new Tls.Module());
+ stream.add_module(new Iq.Module());
+ stream.add_module(new Xep.SrvRecordsTls.Module());
+ stream.add_module(new Xep.InBandRegistration.Module());
+
+ SourceFunc callback = submit_form.callback;
+
+ stream.stream_negotiated.connect(() => {
+ if (callback != null) {
+ Idle.add((owned)callback);
+ }
+ });
+
+ stream.connect.begin(jid.domainpart, (_, res) => {
+ try {
+ stream.connect.end(res);
+ } catch (Error e) {
+ debug("Error connecting to stream: %s", e.message);
+ }
+ if (callback != null) {
+ Idle.add((owned)callback);
+ }
+ });
+
+ yield;
+ if (stream.negotiation_complete) {
+ return yield stream.get_module(Xep.InBandRegistration.Module.IDENTITY).submit_to_server(stream, jid, form);
+ }
+ return null;
}
}