Annotate

mod_vjud/vcard.lib.lua @ 718:a37e4149ccd1

mod_pubsub_feeds: Prepare for making it possible to unsubscribe, and some other minor changes.
author Kim Alvefur <zash@zash.se>
date Wed, 20 Jun 2012 16:08:47 +0200
parent 716:dac33b8f190b
child 732:317e142fe6f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
716
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 -- Copyright (C) 2011-2012 Kim Alvefur
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 --
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 -- This project is MIT/X11 licensed. Please see the
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 -- COPYING file in the source package for more information.
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 --
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 -- TODO
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 -- function lua_to_xep54()
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 -- function lua_to_text()
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 -- replace text_to_xep54() and xep54_to_text() with intermediate lua?
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 local st = require "util.stanza";
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 local t_insert, t_concat = table.insert, table.concat;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 local type = type;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 local next, pairs, ipairs = next, pairs, ipairs;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 local lua_to_text, lua_to_xep54, text_to_lua, text_to_xep54, xep54_to_lua, xep54_to_text;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 local from_text, to_text, from_xep54, to_xep54; --TODO implement these, replace the above
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 local vCard_dtd;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 local function vCard_esc(s)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 return s:gsub("[,:;\\]", "\\%1"):gsub("\n","\\n");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 local function vCard_unesc(s)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 return s:gsub("\\?[\\nt:;,]", {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 ["\\\\"] = "\\",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 ["\\n"] = "\n",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 ["\\t"] = "\t",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 ["\\:"] = ":", -- FIXME Shouldn't need to espace : in values, just params
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 ["\\;"] = ";",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 ["\\,"] = ",",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 [":"] = "\29",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 [";"] = "\30",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 [","] = "\31",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 });
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
39 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
40
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
41 function text_to_xep54(data)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
42 --[[ TODO
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
43 return lua_to_xep54(text_to_lua(data));
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
44 --]]
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
45 data = data
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
46 :gsub("\r\n","\n")
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
47 :gsub("\n ", "")
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
48 :gsub("\n\n+","\n");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
49 local c = st.stanza("xCard", { xmlns = "vcard-temp" });
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
50 for line in data:gmatch("[^\n]+") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
51 local line = vCard_unesc(line);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
52 local name, params, value = line:match("^([-%a]+)(\30?[^\29]*)\29(.*)$");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
53 value = value:gsub("\29",":");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
54 if #params > 0 then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
55 local _params = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
56 for k,isval,v in params:gmatch("\30([^=]+)(=?)([^\30]*)") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
57 k = k:upper();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
58 local _vt = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
59 for _p in v:gmatch("[^\31]+") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
60 _vt[#_vt+1]=_p
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
61 _vt[_p]=true;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
62 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
63 if isval == "=" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
64 _params[k]=_vt;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
65 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
66 _params[k]=true;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
67 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
68 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
69 params = _params;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
70 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
71 if name == "BEGIN" and value == "VCARD" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
72 c:tag("vCard", { xmlns = "vcard-temp" });
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
73 elseif name == "END" and value == "VCARD" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
74 c:up();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
75 elseif vCard_dtd[name] then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
76 local dtd = vCard_dtd[name];
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
77 c:tag(name);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
78 if dtd.types then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
79 for _, t in ipairs(dtd.types) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
80 if ( params.TYPE and params.TYPE[t] == true)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
81 or params[t] == true then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
82 c:tag(t):up();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
83 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
84 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
85 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
86 if dtd.props then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
87 for _, p in ipairs(dtd.props) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
88 if params[p] then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
89 if params[p] == true then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
90 c:tag(p):up();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
91 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
92 for _, prop in ipairs(params[p]) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
93 c:tag(p):text(prop):up();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
94 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
95 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
96 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
97 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
98 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
99 if dtd == "text" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
100 c:text(value);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
101 elseif dtd.value then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
102 c:tag(dtd.value):text(value):up();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
103 elseif dtd.values then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
104 local values = dtd.values;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
105 local i = 1;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
106 local value = "\30"..value;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
107 for p in value:gmatch("\30([^\30]*)") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
108 c:tag(values[i]):text(p):up();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
109 if i < #values then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
110 i = i + 1;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
111 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
112 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
113 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
114 c:up();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
115 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
116 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
117 return c;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
118 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
119
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
120 function text_to_lua(data) --table
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
121 data = data
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
122 :gsub("\r\n","\n")
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
123 :gsub("\n ", "")
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
124 :gsub("\n\n+","\n");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
125 local vCards = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
126 local c; -- current item
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
127 for line in data:gmatch("[^\n]+") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
128 local line = vCard_unesc(line);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
129 local name, params, value = line:match("^([-%a]+)(\30?[^\29]*)\29(.*)$");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
130 value = value:gsub("\29",":");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
131 if #params > 0 then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
132 local _params = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
133 for k,isval,v in params:gmatch("\30([^=]+)(=?)([^\30]*)") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
134 k = k:upper();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
135 local _vt = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
136 for _p in v:gmatch("[^\31]+") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
137 _vt[#_vt+1]=_p
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
138 _vt[_p]=true;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
139 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
140 if isval == "=" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
141 _params[k]=_vt;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
142 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
143 _params[k]=true;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
144 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
145 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
146 params = _params;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
147 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
148 if name == "BEGIN" and value == "VCARD" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
149 c = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
150 vCards[#vCards+1] = c;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
151 elseif name == "END" and value == "VCARD" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
152 c = nil;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
153 elseif vCard_dtd[name] then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
154 local dtd = vCard_dtd[name];
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
155 local p = { name = name };
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
156 c[#c+1]=p;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
157 --c[name]=p;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
158 local up = c;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
159 c = p;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
160 if dtd.types then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
161 for _, t in ipairs(dtd.types) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
162 local t = t:lower();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
163 if ( params.TYPE and params.TYPE[t] == true)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
164 or params[t] == true then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
165 c.TYPE=t;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
166 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
167 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
168 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
169 if dtd.props then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
170 for _, p in ipairs(dtd.props) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
171 if params[p] then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
172 if params[p] == true then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
173 c[p]=true;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
174 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
175 for _, prop in ipairs(params[p]) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
176 c[p]=prop;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
177 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
178 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
179 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
180 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
181 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
182 if dtd == "text" or dtd.value then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
183 t_insert(c, value);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
184 elseif dtd.values then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
185 local value = "\30"..value;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
186 for p in value:gmatch("\30([^\30]*)") do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
187 t_insert(c, p);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
188 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
189 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
190 c = up;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
191 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
192 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
193 return vCards;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
194 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
195
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
196 function to_text(vcard)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
197 local t={};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
198 t_insert(t, "BEGIN:VCARD")
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
199 for i=1,#vcard do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
200 t_insert(t, ("%s:%s"):format(vcard[i].name, t_concat(vcard[i], ";")));
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
201 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
202 t_insert(t, "END:VCARD")
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
203 return t_concat(t,"\n");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
204 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
205
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
206 local function vCard_prop(item) -- single item staza object to text line
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
207 local prop_name = item.name;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
208 local prop_def = vCard_dtd[prop_name];
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
209 if not prop_def then return nil end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
210
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
211 local value, params = "", {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
212
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
213 if prop_def == "text" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
214 value = item:get_text();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
215 elseif type(prop_def) == "table" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
216 if prop_def.value then --single item
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
217 value = item:get_child_text(prop_def.value) or "";
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
218 elseif prop_def.values then --array
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
219 local value_names = prop_def.values;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
220 value = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
221 if value_names.behaviour == "repeat-last" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
222 for i=1,#item do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
223 t_insert(value, item[i]:get_text() or "");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
224 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
225 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
226 for i=1,#value_names do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
227 t_insert(value, item:get_child_text(value_names[i]) or "");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
228 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
229 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
230 elseif prop_def.names then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
231 local names = prop_def.names;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
232 for i=1,#names do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
233 if item:get_child(names[i]) then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
234 value = names[i];
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
235 break;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
236 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
237 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
238 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
239
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
240 if prop_def.props_verbatim then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
241 for k,v in pairs(prop_def.props_verbatim) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
242 params[k] = v;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
243 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
244 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
245
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
246 if prop_def.types then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
247 local types = prop_def.types;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
248 params.TYPE = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
249 for i=1,#types do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
250 if item:get_child(types[i]) then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
251 t_insert(params.TYPE, types[i]:lower());
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
252 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
253 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
254 if #params.TYPE == 0 then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
255 params.TYPE = nil;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
256 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
257 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
258
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
259 if prop_def.props then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
260 local props = prop_def.props;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
261 for i=1,#props do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
262 local prop = props[i]
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
263 local p = item:get_child_text(prop);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
264 if p then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
265 params[prop] = params[prop] or {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
266 t_insert(params[prop], p);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
267 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
268 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
269 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
270 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
271 return nil
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
272 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
273
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
274 if type(value) == "table" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
275 for i=1,#value do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
276 value[i]=vCard_esc(value[i]);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
277 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
278 value = t_concat(value, ";");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
279 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
280 value = vCard_esc(value);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
281 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
282
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
283 if next(params) then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
284 local sparams = "";
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
285 for k,v in pairs(params) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
286 sparams = sparams .. (";%s=%s"):format(k, t_concat(v,","));
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
287 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
288 params = sparams;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
289 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
290 params = "";
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
291 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
292
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
293 return ("%s%s:%s"):format(item.name, params, value)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
294 :gsub(("."):rep(75), "%0\r\n "):gsub("\r\n $","");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
295 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
296
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
297 function xep54_to_text(vCard)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
298 --[[ TODO
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
299 return lua_to_text(xep54_to_lua(vCard))
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
300 --]]
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
301 local r = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
302 t_insert(r, "BEGIN:VCARD");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
303 for i = 1,#vCard do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
304 local item = vCard[i];
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
305 if item.name then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
306 local s = vCard_prop(item);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
307 if s then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
308 t_insert(r, s);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
309 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
310 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
311 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
312 t_insert(r, "END:VCARD");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
313 return t_concat(r, "\r\n");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
314 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
315
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
316 local function xep54_item_to_lua(item)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
317 local prop_name = item.name;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
318 local prop_def = vCard_dtd[prop_name];
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
319 if not prop_def then return nil end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
320
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
321 local prop = { name = prop_name };
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
322
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
323 if prop_def == "text" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
324 prop[1] = item:get_text();
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
325 elseif type(prop_def) == "table" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
326 if prop_def.value then --single item
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
327 prop[1] = item:get_child_text(prop_def.value) or "";
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
328 elseif prop_def.values then --array
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
329 local value_names = prop_def.values;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
330 if value_names.behaviour == "repeat-last" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
331 for i=1,#item do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
332 t_insert(prop, item[i]:get_text() or "");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
333 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
334 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
335 for i=1,#value_names do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
336 t_insert(prop, item:get_child_text(value_names[i]) or "");
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
337 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
338 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
339 elseif prop_def.names then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
340 local names = prop_def.names;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
341 for i=1,#names do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
342 if item:get_child(names[i]) then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
343 prop[1] = names[i];
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
344 break;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
345 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
346 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
347 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
348
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
349 if prop_def.props_verbatim then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
350 for k,v in pairs(prop_def.props_verbatim) do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
351 prop[k] = v;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
352 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
353 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
354
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
355 if prop_def.types then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
356 local types = prop_def.types;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
357 prop.TYPE = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
358 for i=1,#types do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
359 if item:get_child(types[i]) then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
360 t_insert(prop.TYPE, types[i]:lower());
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
361 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
362 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
363 if #prop.TYPE == 0 then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
364 prop.TYPE = nil;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
365 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
366 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
367
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
368 -- A key-value pair, within a key-value pair?
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
369 if prop_def.props then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
370 local params = prop_def.props;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
371 for i=1,#params do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
372 local name = params[i]
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
373 local data = item:get_child_text(name);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
374 if data then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
375 prop[name] = prop[name] or {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
376 t_insert(prop[name], data);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
377 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
378 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
379 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
380 else
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
381 return nil
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
382 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
383
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
384 return prop;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
385 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
386
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
387 local function xep54_vCard_to_lua(vCard)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
388 local tags = vCard.tags;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
389 local t = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
390 for i=1,#tags do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
391 t[i] = xep54_item_to_lua(tags[i]);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
392 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
393 return t
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
394 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
395
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
396 function xep54_to_lua(vCard)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
397 if vCard.attr.xmlns ~= "vcard-temp" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
398 return false
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
399 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
400 if vCard.name == "xCard" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
401 local t = {};
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
402 local vCards = vCard.tags;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
403 for i=1,#vCards do
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
404 local ti = xep54_vCard_to_lua(vCards[i]);
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
405 t[i] = ti;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
406 --t[ti.name] = ti;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
407 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
408 return t
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
409 elseif vCard.name == "vCard" then
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
410 return xep54_vCard_to_lua(vCard)
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
411 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
412 end
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
413
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
414 -- This was adapted from http://xmpp.org/extensions/xep-0054.html#dtd
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
415 vCard_dtd = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
416 VERSION = "text", --MUST be 3.0, so parsing is redundant
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
417 FN = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
418 N = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
419 values = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
420 "FAMILY",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
421 "GIVEN",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
422 "MIDDLE",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
423 "PREFIX",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
424 "SUFFIX",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
425 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
426 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
427 NICKNAME = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
428 PHOTO = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
429 props_verbatim = { ENCODING = { "b" } },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
430 props = { "TYPE" },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
431 value = "BINVAL", --{ "EXTVAL", },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
432 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
433 BDAY = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
434 ADR = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
435 types = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
436 "HOME",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
437 "WORK",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
438 "POSTAL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
439 "PARCEL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
440 "DOM",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
441 "INTL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
442 "PREF",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
443 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
444 values = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
445 "POBOX",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
446 "EXTADD",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
447 "STREET",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
448 "LOCALITY",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
449 "REGION",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
450 "PCODE",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
451 "CTRY",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
452 }
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
453 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
454 LABEL = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
455 types = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
456 "HOME",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
457 "WORK",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
458 "POSTAL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
459 "PARCEL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
460 "DOM",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
461 "INTL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
462 "PREF",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
463 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
464 value = "LINE",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
465 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
466 TEL = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
467 types = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
468 "HOME",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
469 "WORK",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
470 "VOICE",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
471 "FAX",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
472 "PAGER",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
473 "MSG",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
474 "CELL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
475 "VIDEO",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
476 "BBS",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
477 "MODEM",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
478 "ISDN",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
479 "PCS",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
480 "PREF",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
481 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
482 value = "NUMBER",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
483 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
484 EMAIL = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
485 types = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
486 "HOME",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
487 "WORK",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
488 "INTERNET",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
489 "PREF",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
490 "X400",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
491 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
492 value = "USERID",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
493 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
494 JABBERID = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
495 MAILER = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
496 TZ = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
497 GEO = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
498 values = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
499 "LAT",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
500 "LON",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
501 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
502 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
503 TITLE = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
504 ROLE = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
505 LOGO = "copy of PHOTO",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
506 AGENT = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
507 ORG = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
508 values = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
509 behaviour = "repeat-last",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
510 "ORGNAME",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
511 "ORGUNIT",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
512 }
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
513 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
514 CATEGORIES = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
515 values = "KEYWORD",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
516 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
517 NOTE = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
518 PRODID = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
519 REV = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
520 SORTSTRING = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
521 SOUND = "copy of PHOTO",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
522 UID = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
523 URL = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
524 CLASS = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
525 names = { -- The item.name is the value if it's one of these.
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
526 "PUBLIC",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
527 "PRIVATE",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
528 "CONFIDENTIAL",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
529 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
530 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
531 KEY = {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
532 props = { "TYPE" },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
533 value = "CRED",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
534 },
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
535 DESC = "text",
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
536 };
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
537 vCard_dtd.LOGO = vCard_dtd.PHOTO;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
538 vCard_dtd.SOUND = vCard_dtd.PHOTO;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
539
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
540 return {
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
541 text_to_xep54 = text_to_xep54;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
542 text_to_lua = text_to_lua;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
543 xep54_to_text = xep54_to_text;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
544 xep54_to_lua = xep54_to_lua;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
545 --[[ TODO
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
546 from_text = from_text;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
547 to_text = to_text;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
548 from_xep54 = from_xep54;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
549 to_xep54 = to_xep54;
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
550 --]]
dac33b8f190b mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff changeset
551 };