Software /
code /
verse
Annotate
plugins/bind.lua @ 169:4bb1e9c91fbe
plugins.legacy: Try to login anyways, compat for servers not supporting XEP 78 properly.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 15 Dec 2010 15:03:46 +0000 |
parent | 78:f4188eff53a7 |
child | 160:5cbbfe42212e |
rev | line source |
---|---|
9 | 1 local st = require "util.stanza"; |
2 local xmlns_bind = "urn:ietf:params:xml:ns:xmpp-bind"; | |
3 | |
4 function verse.plugins.bind(stream) | |
5 local function handle_features(features) | |
6 if stream.bound then return; end | |
7 stream:debug("Binding resource..."); | |
40
afd037420977
plugins.bind: Requested JID^Wresource should be in <jid/>^W<resource/> tag (thanks Maranda :) )
Matthew Wild <mwild1@gmail.com>
parents:
39
diff
changeset
|
8 stream:send_iq(st.iq({ type = "set" }):tag("bind", {xmlns=xmlns_bind}):tag("resource"):text(stream.resource), |
9 | 9 function (reply) |
10 if reply.attr.type == "result" then | |
11 local result_jid = reply | |
12 :get_child("bind", xmlns_bind) | |
13 :get_child("jid") | |
14 :get_text(); | |
15 stream.username, stream.host, stream.resource = jid.split(result_jid); | |
16 stream.jid, stream.bound = result_jid, true; | |
78
f4188eff53a7
verse.client, verse.plugins.bind, verse.plugins.session: Rename binding-success and binding-failure to bind-success and bind-failure for consistency
Matthew Wild <mwild1@gmail.com>
parents:
43
diff
changeset
|
17 stream:event("bind-success", full_jid); |
9 | 18 elseif reply.attr.type == "error" then |
43
a33036b7e5ab
verse.plugins.bind: Fix incorrect variable name causing traceback on unsuccessful bind
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
19 local err = reply:child_with_name("error"); |
a33036b7e5ab
verse.plugins.bind: Fix incorrect variable name causing traceback on unsuccessful bind
Matthew Wild <mwild1@gmail.com>
parents:
40
diff
changeset
|
20 local type, condition, text = reply:get_error(); |
78
f4188eff53a7
verse.client, verse.plugins.bind, verse.plugins.session: Rename binding-success and binding-failure to bind-success and bind-failure for consistency
Matthew Wild <mwild1@gmail.com>
parents:
43
diff
changeset
|
21 stream:event("bind-failure", { error = condition, text = text, type = type }); |
9 | 22 end |
23 end); | |
24 end | |
25 stream:hook("stream-features", handle_features, 200); | |
26 return true; | |
27 end | |
28 |