12 local st = verse or require "util.stanza"; |
12 local st = verse or require "util.stanza"; |
13 local t_insert, t_concat = table.insert, table.concat; |
13 local t_insert, t_concat = table.insert, table.concat; |
14 local type = type; |
14 local type = type; |
15 local next, pairs, ipairs = next, pairs, ipairs; |
15 local next, pairs, ipairs = next, pairs, ipairs; |
16 |
16 |
17 module "vcard" |
17 local lua_to_text, lua_to_xep54, text_to_lua, text_to_xep54, xep54_to_lua, xep54_to_text; |
|
18 --[[ TODO local from_text, to_text, from_xep54, to_xep54; --]] |
|
19 |
18 |
20 |
19 local vCard_dtd; |
21 local vCard_dtd; |
20 |
22 |
21 local function vCard_esc(s) |
23 local function vCard_esc(s) |
22 return s:gsub("[,:;\\]", "\\%1"):gsub("\n","\\n"); |
24 return s:gsub("[,:;\\]", "\\%1"):gsub("\n","\\n"); |
271 |
273 |
272 return ("%s%s:%s"):format(item.name, params, value) |
274 return ("%s%s:%s"):format(item.name, params, value) |
273 :gsub(("."):rep(75), "%0\r\n "):gsub("\r\n $",""); |
275 :gsub(("."):rep(75), "%0\r\n "):gsub("\r\n $",""); |
274 end |
276 end |
275 |
277 |
276 function xep54_to_text(vCard) |
278 local function xep54_to_text(vCard) |
277 --[[ TODO |
279 --[[ TODO |
278 return lua_to_text(xep54_to_lua(vCard)) |
280 return lua_to_text(xep54_to_lua(vCard)) |
279 --]] |
281 --]] |
280 local r = {}; |
282 local r = {}; |
281 t_insert(r, "BEGIN:VCARD"); |
283 t_insert(r, "BEGIN:VCARD"); |
513 }, |
515 }, |
514 DESC = "text", |
516 DESC = "text", |
515 }; |
517 }; |
516 vCard_dtd.LOGO = vCard_dtd.PHOTO; |
518 vCard_dtd.LOGO = vCard_dtd.PHOTO; |
517 vCard_dtd.SOUND = vCard_dtd.PHOTO; |
519 vCard_dtd.SOUND = vCard_dtd.PHOTO; |
518 return _M |
520 |
|
521 return { |
|
522 text_to_xep54 = text_to_xep54; |
|
523 text_to_lua = text_to_lua; |
|
524 xep54_to_text = xep54_to_text; |
|
525 xep54_to_lua = xep54_to_lua; |
|
526 --[[ TODO |
|
527 from_text = from_text; |
|
528 to_text = to_text; |
|
529 from_xep54 = from_xep54; |
|
530 to_xep54 = to_xep54; |
|
531 --]] |
|
532 }; |