Comparison

tools/xep227toprosody.lua @ 3710:59fbe4536c69

tools/xep227toprosody.lua: Rename ns_xep227 to xmlns_xep227 for consistency with main Prosody code
author Matthew Wild <mwild1@gmail.com>
date Tue, 07 Dec 2010 19:22:08 +0000
parent 3709:db1c1ddc79e8
child 5091:dbc483d06a07
comparison
equal deleted inserted replaced
3709:db1c1ddc79e8 3710:59fbe4536c69
39 local xmppstream = require "util.xmppstream"; 39 local xmppstream = require "util.xmppstream";
40 local new_xmpp_handlers = xmppstream.new_sax_handlers; 40 local new_xmpp_handlers = xmppstream.new_sax_handlers;
41 local dm = require "util.datamanager" 41 local dm = require "util.datamanager"
42 dm.set_data_path("data"); 42 dm.set_data_path("data");
43 43
44 local ns_xep227 = "http://www.xmpp.org/extensions/xep-0227.html#ns";
45 local ns_separator = xmppstream.ns_separator; 44 local ns_separator = xmppstream.ns_separator;
46 local ns_pattern = xmppstream.ns_pattern; 45 local ns_pattern = xmppstream.ns_pattern;
46
47 local xmlns_xep227 = "http://www.xmpp.org/extensions/xep-0227.html#ns";
47 48
48 ----------------------------------------------------------------------- 49 -----------------------------------------------------------------------
49 50
50 function store_vcard(username, host, stanza) 51 function store_vcard(username, host, stanza)
51 -- create or update vCard for username@host 52 -- create or update vCard for username@host
145 local user_name = ""; 146 local user_name = "";
146 147
147 148
148 local cb = { 149 local cb = {
149 stream_tag = "user", 150 stream_tag = "user",
150 stream_ns = ns_xep227, 151 stream_ns = xmlns_xep227,
151 }; 152 };
152 function cb.streamopened(session, attr) 153 function cb.streamopened(session, attr)
153 session.notopen = false; 154 session.notopen = false;
154 user_name = attr.name; 155 user_name = attr.name;
155 store_password(user_name, curr_host, attr.password); 156 store_password(user_name, curr_host, attr.password);
194 --io.write("+ ", string.rep(" ", count), name, " (", curr_ns, ")", "\n") 195 --io.write("+ ", string.rep(" ", count), name, " (", curr_ns, ")", "\n")
195 --count = count + 1; 196 --count = count + 1;
196 if curr_host ~= "" then 197 if curr_host ~= "" then
197 -- forward to xmlhandlers 198 -- forward to xmlhandlers
198 user_handlers:StartElement(elementname, attributes); 199 user_handlers:StartElement(elementname, attributes);
199 elseif (curr_ns == ns_xep227) and (name == "host") then 200 elseif (curr_ns == xmlns_xep227) and (name == "host") then
200 curr_host = attributes["jid"]; -- start of host element 201 curr_host = attributes["jid"]; -- start of host element
201 print("Begin parsing host "..curr_host); 202 print("Begin parsing host "..curr_host);
202 elseif (curr_ns ~= ns_xep227) or (name ~= "server-data") then 203 elseif (curr_ns ~= xmlns_xep227) or (name ~= "server-data") then
203 io.stderr:write("Unhandled XML element: ", name, "\n"); 204 io.stderr:write("Unhandled XML element: ", name, "\n");
204 os.exit(1); 205 os.exit(1);
205 end 206 end
206 end 207 end
207 208
212 curr_ns, name = "", curr_ns; 213 curr_ns, name = "", curr_ns;
213 end 214 end
214 --count = count - 1; 215 --count = count - 1;
215 --io.write("- ", string.rep(" ", count), name, " (", curr_ns, ")", "\n") 216 --io.write("- ", string.rep(" ", count), name, " (", curr_ns, ")", "\n")
216 if curr_host ~= "" then 217 if curr_host ~= "" then
217 if (curr_ns == ns_xep227) and (name == "host") then 218 if (curr_ns == xmlns_xep227) and (name == "host") then
218 print("End parsing host "..curr_host); 219 print("End parsing host "..curr_host);
219 curr_host = "" -- end of host element 220 curr_host = "" -- end of host element
220 else 221 else
221 -- forward to xmlhandlers 222 -- forward to xmlhandlers
222 user_handlers:EndElement(elementname); 223 user_handlers:EndElement(elementname);
223 end 224 end
224 elseif (curr_ns ~= ns_xep227) or (name ~= "server-data") then 225 elseif (curr_ns ~= xmlns_xep227) or (name ~= "server-data") then
225 io.stderr:write("Unhandled XML element: ", name, "\n"); 226 io.stderr:write("Unhandled XML element: ", name, "\n");
226 os.exit(1); 227 os.exit(1);
227 end 228 end
228 end 229 end
229 230