Software /
code /
prosody-modules
Annotate
mod_vjud/vcard.lib.lua @ 733:dd3b30c0dc8a
mod_vjud: Switch first and last name in results to be correct.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 01 Jul 2012 13:15:40 +0200 |
parent | 732:317e142fe6f1 |
child | 734:81de1e446bfe |
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 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
8 -- Fix folding. |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 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
|
11 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
|
12 local type = type; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 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
|
14 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
15 local from_text, to_text, from_xep54, to_xep54; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
16 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
17 local line_sep = "\n"; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
18 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
19 local vCard_dtd; -- See end of file |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
21 local function fold_line() |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
22 error "Not implemented" --TODO |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
23 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
24 local function unfold_line() |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
25 error "Not implemented" |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
26 -- gsub("\r?\n[ \t]([^\r\n])", "%1"); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
27 end |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 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
|
30 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
|
31 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 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
|
34 return s:gsub("\\?[\\nt:;,]", { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 ["\\\\"] = "\\", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 ["\\n"] = "\n", |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
37 ["\\r"] = "\r", |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 ["\\t"] = "\t", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 ["\\:"] = ":", -- 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
|
40 ["\\;"] = ";", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 ["\\,"] = ",", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 [":"] = "\29", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 [";"] = "\30", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 [","] = "\31", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 }); |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
48 local function item_to_xep54(item) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
49 local t = st.stanza(item.name, { xmlns = "vcard-temp" }); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
50 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
51 local prop_def = vCard_dtd[item.name]; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
52 if prop_def == "text" then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
53 t:text(item[1]); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
54 elseif type(prop_def) == "table" then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
55 if prop_def.types and item.TYPE then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
56 if type(item.TYPE) == "table" then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
57 for _,v in pairs(prop_def.types) do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
58 for _,typ in pairs(item.TYPE) do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
59 if typ:upper() == v then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
60 t:tag(v):up(); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
61 break; |
716
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 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
64 end |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
65 else |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
66 t:tag(item.TYPE:upper()):up(); |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
67 end |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
68 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
69 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
70 if prop_def.props then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
71 for _,v in pairs(prop_def.props) do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
72 if item[v] then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
73 t:tag(v):up(); |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
74 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
75 end |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
76 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
77 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
78 if prop_def.value then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
79 t:tag(prop_def.value):text(item[1]):up(); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
80 elseif prop_def.values then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
81 local prop_def_values = prop_def.values; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
82 local repeat_last = prop_def_values.behaviour == "repeat-last" and prop_def_values[#prop_def_values]; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
83 for i=1,#item do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
84 t:tag(prop_def.values[i] or repeat_last):text(item[i]):up(); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
85 end |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
86 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
87 end |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
88 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
89 return t; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
90 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
91 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
92 local function vcard_to_xep54(vCard) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
93 local t = st.stanza("vCard", { xmlns = "vcard-temp" }); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
94 for i=1,#vCard do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
95 t:add_child(item_to_xep54(vCard[i])); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
96 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
97 return t; |
716
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 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
100 function to_xep54(vCards) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
101 if vCards[1].name then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
102 return vcard_to_xep54(vCards) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
103 else |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
104 local t = st.stanza("xCard", { xmlns = "vcard-temp" }); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
105 for i=1,#vCards do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
106 t:add_child(vcard_to_xep54(vCards[i])); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
107 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
108 return t; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
109 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
110 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
111 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
112 function from_text(data) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
113 data = data -- unfold and remove empty lines |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
114 :gsub("\r\n","\n") |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
115 :gsub("\n ", "") |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
116 :gsub("\n\n+","\n"); |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
117 local vCards = {}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
118 local c; -- current item |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 value = value:gsub("\29",":"); |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
123 if #params > 0 then |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
124 local _params = {}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
125 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
|
126 k = k:upper(); |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
127 local _vt = {}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
128 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
|
129 _vt[#_vt+1]=_p |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
130 _vt[_p]=true; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
131 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
132 if isval == "=" then |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
133 _params[k]=_vt; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
134 else |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
135 _params[k]=true; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
136 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
137 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
138 params = _params; |
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 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
|
141 c = {}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
142 vCards[#vCards+1] = c; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
143 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
|
144 c = nil; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
145 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
|
146 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
|
147 local p = { name = name }; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
148 c[#c+1]=p; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
149 --c[name]=p; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
150 local up = c; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
151 c = p; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
152 if dtd.types then |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
153 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
|
154 local t = t:lower(); |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
155 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
|
156 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
|
157 c.TYPE=t; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
158 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
159 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
160 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
161 if dtd.props then |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
162 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
|
163 if params[p] then |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
164 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
|
165 c[p]=true; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
166 else |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
167 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
|
168 c[p]=prop; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
169 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
170 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
171 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
172 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
173 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
174 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
|
175 t_insert(c, value); |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
176 elseif dtd.values then |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
177 local value = "\30"..value; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
178 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
|
179 t_insert(c, p); |
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 c = up; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
183 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
184 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
185 return vCards; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
186 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
187 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
188 local function item_to_text(item) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
189 local value = {}; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
190 for i=1,#item do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
191 value[i] = vCard_esc(item[i]); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
192 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
193 value = t_concat(value, ";"); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
194 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
195 local params = ""; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
196 for k,v in pairs(item) do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
197 if type(k) == "string" and k ~= "name" then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
198 params = params .. (";%s=%s"):format(k, type(v) == "table" and t_concat(v,",") or v); |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
199 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
200 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
201 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
202 return ("%s%s:%s"):format(item.name, params, value) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
203 end |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
204 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
205 local function vcard_to_text(vcard) |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
206 local t={}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
207 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
|
208 for i=1,#vcard do |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
209 t_insert(t, item_to_text(vcard[i])); |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
210 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
211 t_insert(t, "END:VCARD") |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
212 return t_concat(t, line_sep); |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
213 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
214 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
215 function to_text(vCards) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
216 if vCards[1].name then |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
217 return vcard_to_text(vCards) |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
218 else |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
219 local t = {}; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
220 for i=1,#vCards do |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
221 t[i]=vcard_to_text(vCards[i]); |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
222 end |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
223 return t_concat(t, line_sep); |
716
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 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
226 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
227 local function from_xep54_item(item) |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
232 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
|
233 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
245 else |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
246 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
|
247 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
|
248 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
249 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
250 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
|
251 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
|
252 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
|
253 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
|
254 prop[1] = names[i]; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
255 break; |
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 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
259 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
260 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
|
261 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
|
262 prop[k] = v; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
263 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
264 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
265 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
266 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
|
267 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
|
268 prop.TYPE = {}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
269 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
|
270 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
|
271 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
|
272 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
273 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
274 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
|
275 prop.TYPE = nil; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
276 end |
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 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
279 -- 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
|
280 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
|
281 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
|
282 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
|
283 local name = params[i] |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
284 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
|
285 if data then |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
286 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
|
287 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
|
288 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
289 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
290 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
291 else |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
292 return nil |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
293 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
294 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
295 return prop; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
296 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
297 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
298 local function from_xep54_vCard(vCard) |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
299 local tags = vCard.tags; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
300 local t = {}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
301 for i=1,#tags do |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
302 t[i] = from_xep54_item(tags[i]); |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
303 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
304 return t |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
305 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
306 |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
307 function from_xep54(vCard) |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
308 if vCard.attr.xmlns ~= "vcard-temp" then |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
309 return nil, "wrong-xmlns"; |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
310 end |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
311 if vCard.name == "xCard" then -- A collection of vCards |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
312 local t = {}; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
313 local vCards = vCard.tags; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
314 for i=1,#vCards do |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
315 local ti = from_xep54_vCard(vCards[i]); |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
316 t[i] = ti; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
317 --t[ti.name] = ti; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
318 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
319 return t |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
320 elseif vCard.name == "vCard" then -- A single vCard |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
321 return from_xep54_vCard(vCard) |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
322 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
323 end |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
324 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
325 -- 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
|
326 vCard_dtd = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
327 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
|
328 FN = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
329 N = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
330 values = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
331 "FAMILY", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
332 "GIVEN", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
333 "MIDDLE", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
334 "PREFIX", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
335 "SUFFIX", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
336 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
337 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
338 NICKNAME = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
339 PHOTO = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
340 props_verbatim = { ENCODING = { "b" } }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
341 props = { "TYPE" }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
342 value = "BINVAL", --{ "EXTVAL", }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
343 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
344 BDAY = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
345 ADR = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
346 types = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
347 "HOME", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
348 "WORK", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
349 "POSTAL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
350 "PARCEL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
351 "DOM", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
352 "INTL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
353 "PREF", |
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 values = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
356 "POBOX", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
357 "EXTADD", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
358 "STREET", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
359 "LOCALITY", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
360 "REGION", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
361 "PCODE", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
362 "CTRY", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
363 } |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
364 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
365 LABEL = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
366 types = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
367 "HOME", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
368 "WORK", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
369 "POSTAL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
370 "PARCEL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
371 "DOM", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
372 "INTL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
373 "PREF", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
374 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
375 value = "LINE", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
376 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
377 TEL = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
378 types = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
379 "HOME", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
380 "WORK", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
381 "VOICE", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
382 "FAX", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
383 "PAGER", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
384 "MSG", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
385 "CELL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
386 "VIDEO", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
387 "BBS", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
388 "MODEM", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
389 "ISDN", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
390 "PCS", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
391 "PREF", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
392 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
393 value = "NUMBER", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
394 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
395 EMAIL = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
396 types = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
397 "HOME", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
398 "WORK", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
399 "INTERNET", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
400 "PREF", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
401 "X400", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
402 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
403 value = "USERID", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
404 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
405 JABBERID = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
406 MAILER = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
407 TZ = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
408 GEO = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
409 values = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
410 "LAT", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
411 "LON", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
412 }, |
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 TITLE = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
415 ROLE = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
416 LOGO = "copy of PHOTO", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
417 AGENT = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
418 ORG = { |
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 behaviour = "repeat-last", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
421 "ORGNAME", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
422 "ORGUNIT", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
423 } |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
424 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
425 CATEGORIES = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
426 values = "KEYWORD", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
427 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
428 NOTE = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
429 PRODID = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
430 REV = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
431 SORTSTRING = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
432 SOUND = "copy of PHOTO", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
433 UID = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
434 URL = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
435 CLASS = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
436 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
|
437 "PUBLIC", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
438 "PRIVATE", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
439 "CONFIDENTIAL", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
440 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
441 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
442 KEY = { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
443 props = { "TYPE" }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
444 value = "CRED", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
445 }, |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
446 DESC = "text", |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
447 }; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
448 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
|
449 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
|
450 |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
451 return { |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
452 from_text = from_text; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
453 to_text = to_text; |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
454 |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
455 from_xep54 = from_xep54; |
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
456 to_xep54 = to_xep54; |
732
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
457 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
458 -- COMPAT: |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
459 lua_to_text = to_text; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
460 lua_to_xep54 = to_xep54; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
461 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
462 text_to_lua = from_text; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
463 text_to_xep54 = function (...) return to_xep54(from_text(...)); end; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
464 |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
465 xep54_to_lua = from_xep54; |
317e142fe6f1
mod_vjud: Update util.vcard from verse
Kim Alvefur <zash@zash.se>
parents:
716
diff
changeset
|
466 xep54_to_text = function (...) return to_text(from_xep54(...)) end; |
716
dac33b8f190b
mod_vjud: Depends on vcard lib from verse, so add that.
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
467 }; |