1 ;;; vm-vcard.el --- vcard parsing and formatting routines for VM
3 ;; Copyright (C) 1997, 2000 Noah S. Friedman
5 ;; Author: Noah Friedman <friedman@splode.com>
6 ;; Maintainer: friedman@splode.com
7 ;; Keywords: extensions
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
31 (and (string-lessp vcard-api-version "2.0")
32 (error "vm-vcard.el requires vcard API version 2.0 or later."))
35 (defvar vm-vcard-format-function nil
36 "*Function to use for formatting vcards; if nil, use default.")
39 (defvar vm-vcard-filter nil
40 "*Filter function to use for formatting vcards; if nil, use default.")
43 (defun vm-mime-display-internal-text/x-vcard (layout)
44 (let ((inhibit-read-only t)
45 (buffer-read-only nil))
46 (insert (vm-vcard-format-layout layout)))
49 (defun vm-vcard-format-layout (layout)
50 (let* ((beg (vm-mm-layout-body-start layout))
51 (end (vm-mm-layout-body-end layout))
52 (buf (if (markerp beg) (marker-buffer beg) (current-buffer)))
53 (raw (vm-vcard-decode (save-excursion
57 (buffer-substring beg end)))
59 (vcard-pretty-print-function (or vm-vcard-format-function
60 vcard-pretty-print-function)))
61 (vcard-pretty-print (vcard-parse-string raw vm-vcard-filter))))
63 (defun vm-vcard-decode (string layout)
64 (let ((buf (generate-new-buffer " *vcard decoding*")))
68 (vm-mime-transfer-decode-region layout (point-min) (point-max))
69 (setq string (buffer-substring (point-min) (point-max))))
73 (defun vm-vcard-format-simple (vcard)
74 (concat "\n\n--\n" (vcard-format-sample-string vcard) "\n\n"))
78 ;;; vm-vcard.el ends here.