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