commit-womb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-womb] addressbook addressbook.el


From: Xavier Maillard
Subject: [commit-womb] addressbook addressbook.el
Date: Tue, 08 May 2007 19:19:39 +0000

CVSROOT:        /sources/womb
Module name:    addressbook
Changes by:     Xavier Maillard <zeDek> 07/05/08 19:19:39

Modified files:
        .              : addressbook.el 

Log message:
        Drop (now useless) url package dependance

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/addressbook/addressbook.el?cvsroot=womb&r1=1.25&r2=1.26

Patches:
Index: addressbook.el
===================================================================
RCS file: /sources/womb/addressbook/addressbook.el,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- addressbook.el      8 May 2007 15:56:09 -0000       1.25
+++ addressbook.el      8 May 2007 19:19:39 -0000       1.26
@@ -5,7 +5,7 @@
 ;; Maintainer: Jose E. Marchesi
 ;; Keywords: contacts, applications
 
-;; $Id: addressbook.el,v 1.25 2007/05/08 15:56:09 zeDek Exp $
+;; $Id: addressbook.el,v 1.26 2007/05/08 19:19:39 zeDek Exp $
 
 ;; This file is NOT part of GNU Emacs.
 
@@ -75,7 +75,6 @@
 
 (eval-when-compile (require 'cl))
 (require 'vcard)
-(require 'url)
 (require 'mm-decode)
 
 ;;;; Constants
@@ -835,6 +834,11 @@
                'title t)))))
 
 (defun addrbook-contact-display-attribute-photo-logo (attr-index)
+  "Display photo from ATTR-INDEX.
+Only display it if not already displayed and/or image type is
+supported and if `display-images-p' is non nil.
+
+ATTR-INDEX can represent eith an inlined data or an offline url."
   ;; Photographs has a type and may be:
   ;;
   ;; 1. Inline
@@ -857,21 +861,23 @@
                image-type
                (image-type-available-p image-type)
                (not (addrbook-contact-photo-displayed-p)))
+
       ;; Get image data
+      (let ((image-data
       (if (equal photo-value "url")
           (save-excursion
-            (let ((image-buffer (url-retrieve-synchronously attr-value)))
-              (if image-buffer
-                  (let ((mime-handle nil))
-                    (set-buffer image-buffer)
-                    (re-search-forward "^\r?$" nil 1)
-                    (forward-line)
-                    (delete-region (point-min) (point))
-                    (setq image-data (buffer-substring-no-properties 
(point-min) (point-max)))
-                    (kill-buffer image-buffer)))))
-        ;; Value is the image data
-        (setq image-data attr-value))
+                  ;; FIXME: use a regexp to do pattern matching
+                  (let ((filename
+                         (if (string-match "\\`file:\\(.+\\)" attr-value)
+                             (match-string 1 attr-value))))
+                    (if (and filename (file-readable-p filename))
+                        (with-temp-buffer
+                          (insert-file-contents-literally filename)
+                          (string-as-unibyte (buffer-string))))))
+              attr-value)))
+
       ;; Display the image
+       ;; FIXME: hide photo filed when displaying image
       (save-excursion
         (goto-char (point-min))
         (goto-char (line-end-position))
@@ -880,7 +886,7 @@
                       (propertize "[photo]"
                                   'identification-photo t
                                   'attr-index attr-index
-                                  'attr-subindex nil))))))
+                                   'attr-subindex nil)))))))
 
 (defun addrbook-contact-display-attribute-regular (attr-index)
   (let* ((card (addrbook-get-card addrbook-current-card))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]