Software /
code /
prosody
Annotate
tools/openfire2prosody.lua @ 5089:a5b683909f79
tools/openfire2prosody: Initial commit.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 11 Aug 2012 06:14:12 +0500 |
child | 5217:f2becd36d1d0 |
rev | line source |
---|---|
5089
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env lua |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 -- Prosody IM |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2008-2009 Waqas Hussain |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 -- |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 -- COPYING file in the source package for more information. |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 -- |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
9 package.path = package.path..";../?.lua"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 package.cpath = package.cpath..";../?.so"; -- needed for util.pposix used in datamanager |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 -- ugly workaround for getting datamanager to work outside of prosody :( |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 prosody = { }; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
14 prosody.platform = "unknown"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 if os.getenv("WINDIR") then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 prosody.platform = "windows"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 elseif package.config:sub(1,1) == "/" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 prosody.platform = "posix"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 local lxp = require "lxp"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 local st = require "util.stanza"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 local parse_xml = (function() |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 local ns_prefixes = { |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 ["http://www.w3.org/XML/1998/namespace"] = "xml"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 }; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
28 local ns_separator = "\1"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
29 local ns_pattern = "^([^"..ns_separator.."]*)"..ns_separator.."?(.*)$"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
30 return function(xml) |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
31 local handler = {}; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
32 local stanza = st.stanza("root"); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
33 function handler:StartElement(tagname, attr) |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
34 local curr_ns,name = tagname:match(ns_pattern); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
35 if name == "" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
36 curr_ns, name = "", curr_ns; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
37 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
38 if curr_ns ~= "" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
39 attr.xmlns = curr_ns; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
40 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
41 for i=1,#attr do |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
42 local k = attr[i]; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
43 attr[i] = nil; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
44 local ns, nm = k:match(ns_pattern); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
45 if nm ~= "" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 ns = ns_prefixes[ns]; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 if ns then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
48 attr[ns..":"..nm] = attr[k]; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
49 attr[k] = nil; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
50 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
51 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
52 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
53 stanza:tag(name, attr); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
54 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
55 function handler:CharacterData(data) |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
56 stanza:text(data); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
57 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
58 function handler:EndElement(tagname) |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
59 stanza:up(); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
60 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
61 local parser = lxp.new(handler, "\1"); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
62 local ok, err, line, col = parser:parse(xml); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
63 if ok then ok, err, line, col = parser:parse(); end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
64 --parser:close(); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
65 if ok then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
66 return stanza.tags[1]; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
67 else |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
68 return ok, err.." (line "..line..", col "..col..")"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
69 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
70 end; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
71 end)(); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
72 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
73 ----------------------------------------------------------------------- |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
74 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
75 package.loaded["util.logger"] = {init = function() return function() end; end} |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
76 local dm = require "util.datamanager" |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
77 dm.set_data_path("data"); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
78 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
79 local arg = ...; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
80 local help = "/? -? ? /h -h /help -help --help"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
81 if not arg or help:find(arg, 1, true) then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
82 print([[Openfire importer for Prosody |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
83 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
84 Usage: openfire2prosody.lua filename.xml hostname |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
85 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
86 ]]); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
87 os.exit(1); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
88 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
89 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
90 local host = select(2, ...) or "localhost"; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
91 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
92 local file = assert(io.open(arg)); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
93 local data = assert(file:read("*a")); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
94 file:close(); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
95 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
96 local xml = assert(parse_xml(data)); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
97 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
98 assert(xml.name == "Openfire", "The input file is not an Openfire XML export"); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
99 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
100 local substatus_mapping = { ["0"] = "none", ["1"] = "to", ["2"] = "from", ["3"] = "both" }; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
101 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
102 for _,tag in ipairs(xml.tags) do |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
103 if tag.name == "User" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
104 local username, password, roster; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
105 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
106 for _,tag in ipairs(tag.tags) do |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
107 if tag.name == "Username" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
108 username = tag:get_text(); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
109 elseif tag.name == "Password" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
110 password = tag:get_text(); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
111 elseif tag.name == "Roster" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
112 roster = {}; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
113 local pending = {}; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
114 for _,tag in ipairs(tag.tags) do |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
115 if tag.name == "Item" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
116 local jid = assert(tag.attr.jid, "Roster item has no JID"); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
117 if tag.attr.substatus ~= "-1" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
118 local item = {}; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
119 item.name = tag.attr.name; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
120 item.subscription = assert(substatus_mapping[tag.attr.substatus], "invalid substatus"); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
121 item.ask = tag.attr.askstatus == "0" and "subscribe" or nil; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
122 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
123 local groups = {}; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
124 for _,tag in ipairs(tag) do |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
125 if tag.name == "Group" then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
126 groups[tag:get_text()] = true; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
127 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
128 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
129 item.groups = groups; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
130 roster[jid] = item; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
131 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
132 if tag.attr.recvstatus == "1" then pending[jid] = true; end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
133 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
134 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
135 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
136 if next(pending) then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
137 roster[false] = { pending = pending }; |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
138 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
139 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
140 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
141 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
142 assert(username and password, "No username or password"); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
143 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
144 local ret, err = dm.store(username, host, "accounts", {password = password}); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
145 print("["..(err or "success").."] stored account: "..username.."@"..host.." = "..password); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
146 |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
147 if roster then |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
148 local ret, err = dm.store(username, host, "roster", roster); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
149 print("["..(err or "success").."] stored roster: "..username.."@"..host.." = "..password); |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
150 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
151 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
152 end |
a5b683909f79
tools/openfire2prosody: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
153 |