emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/gnus/mail-source.el,v


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/gnus/mail-source.el,v
Date: Sun, 28 Oct 2007 09:19:11 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Miles Bader <miles>     07/10/28 09:18:40

Index: lisp/gnus/mail-source.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/mail-source.el,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- lisp/gnus/mail-source.el    26 Jul 2007 05:27:00 -0000      1.27
+++ lisp/gnus/mail-source.el    28 Oct 2007 09:18:30 -0000      1.28
@@ -34,8 +34,7 @@
 (eval-and-compile
   (autoload 'pop3-movemail "pop3")
   (autoload 'pop3-get-message-count "pop3")
-  (autoload 'nnheader-cancel-timer "nnheader")
-  (autoload 'nnheader-run-at-time "nnheader"))
+  (autoload 'nnheader-cancel-timer "nnheader"))
 (require 'format-spec)
 (require 'mm-util)
 (require 'message) ;; for `message-directory'
@@ -111,7 +110,7 @@
                                           (const :format "" :value :port)
                                           (choice :tag "Port"
                                                   :value "pop3"
-                                                  (number :format "%v")
+                                                  (integer :format "%v")
                                                   (string :format "%v")))
                                    (group :inline t
                                           (const :format "" :value :user)
@@ -127,13 +126,15 @@
                                           (choice :tag "Prescript"
                                                   :value nil
                                                   (string :format "%v")
-                                                  (function :format "%v")))
+                                                  (function :format "%v")
+                                                  (const :tag "None" nil)))
                                    (group :inline t
                                           (const :format "" :value :postscript)
                                           (choice :tag "Postscript"
                                                   :value nil
                                                   (string :format "%v")
-                                                  (function :format "%v")))
+                                                  (function :format "%v")
+                                                  (const :tag "None" nil)))
                                    (group :inline t
                                           (const :format "" :value :function)
                                           (function :tag "Function"))
@@ -146,7 +147,14 @@
                                                   (const apop)))
                                    (group :inline t
                                           (const :format "" :value :plugged)
-                                          (boolean :tag "Plugged"))))
+                                          (boolean :tag "Plugged"))
+                                   (group :inline t
+                                          (const :format "" :value :stream)
+                                          (choice :tag "Stream"
+                                                  :value nil
+                                                  (const :tag "Clear" nil)
+                                                  (const starttls)
+                                                  (const :tag "SSL/TLS" 
ssl)))))
                   (cons :tag "Maildir (qmail, postfix...)"
                         (const :format "" maildir)
                         (checklist :tag "Options" :greedy t
@@ -166,7 +174,7 @@
                                           (const :format "" :value :port)
                                           (choice :tag "Port"
                                                   :value 143
-                                                  number string))
+                                                  integer string))
                                    (group :inline t
                                           (const :format "" :value :user)
                                           (string :tag "User"))
@@ -269,7 +277,7 @@
   :group 'mail-source
   :type 'integer)
 
-(defcustom mail-source-delete-incoming t
+(defcustom mail-source-delete-incoming nil
   "*If non-nil, delete incoming files after handling.
 If t, delete immediately, if nil, never delete.  If a positive number, delete
 files older than number of days."
@@ -350,7 +358,8 @@
        (:program)
        (:function)
        (:password)
-       (:authentication password))
+       (:authentication password)
+       (:stream nil))
       (maildir
        (:path (or (getenv "MAILDIR") "~/Maildir/"))
        (:subdirs ("cur" "new"))
@@ -502,7 +511,8 @@
            (when (file-exists-p mail-source-crash-box)
              (message "Processing mail from %s..." mail-source-crash-box)
              (setq found (mail-source-callback
-                          callback mail-source-crash-box)))
+                          callback mail-source-crash-box))
+             (mail-source-delete-crash-box))
            (+ found
               (if (or debug-on-quit debug-on-error)
                   (funcall function source callback)
@@ -552,16 +562,16 @@
          (delete-file ffile))))))
 
 (defun mail-source-callback (callback info)
-  "Call CALLBACK on the mail file, and then remove the mail file.
-Pass INFO on to CALLBACK."
+  "Call CALLBACK on the mail file.  Pass INFO on to CALLBACK."
   (if (or (not (file-exists-p mail-source-crash-box))
          (zerop (nth 7 (file-attributes mail-source-crash-box))))
       (progn
        (when (file-exists-p mail-source-crash-box)
          (delete-file mail-source-crash-box))
        0)
-    (prog1
-       (funcall callback mail-source-crash-box info)
+    (funcall callback mail-source-crash-box info)))
+
+(defun mail-source-delete-crash-box ()
       (when (file-exists-p mail-source-crash-box)
        ;; Delete or move the incoming mail out of the way.
        (if (eq mail-source-delete-incoming t)
@@ -578,7 +588,7 @@
            (when (natnump mail-source-delete-incoming)
              (mail-source-delete-old-incoming
               mail-source-delete-incoming
-              mail-source-delete-old-incoming-confirm))))))))
+          mail-source-delete-old-incoming-confirm))))))
 
 (defun mail-source-movemail (from to)
   "Move FROM to TO using movemail."
@@ -670,12 +680,20 @@
     (sleep-for delay)))
 
 (defun mail-source-call-script (script)
-  (let ((background nil))
+  (let ((background nil)
+       (stderr (get-buffer-create " *mail-source-stderr*"))
+       result)
     (when (string-match "& *$" script)
       (setq script (substring script 0 (match-beginning 0))
            background 0))
+    (setq result
     (call-process shell-file-name nil background nil
-                 shell-command-switch script)))
+                       shell-command-switch script))
+    (when (and result
+              (not (zerop result)))
+      (set-buffer stderr)
+      (message "Mail source error: %s" (buffer-string)))
+    (kill-buffer stderr)))
 
 ;;;
 ;;; Different fetchers
@@ -692,7 +710,8 @@
          (prog1
              (mail-source-callback callback path)
            (mail-source-run-script
-            postscript (format-spec-make ?t mail-source-crash-box)))
+            postscript (format-spec-make ?t mail-source-crash-box))
+           (mail-source-delete-crash-box))
        0))))
 
 (defun mail-source-fetch-directory (source callback)
@@ -707,13 +726,15 @@
        (when (and (file-regular-p file)
                   (funcall predicate file)
                   (mail-source-movemail file mail-source-crash-box))
-         (incf found (mail-source-callback callback file))))
+         (incf found (mail-source-callback callback file))
       (mail-source-run-script postscript (format-spec-make ?t path))
+         (mail-source-delete-crash-box)))
       found)))
 
 (defun mail-source-fetch-pop (source callback)
   "Fetcher for single-file sources."
   (mail-source-bind (pop source)
+    ;; fixme: deal with stream type in format specs
     (mail-source-run-script
      prescript
      (format-spec-make ?p password ?t mail-source-crash-box
@@ -748,7 +769,8 @@
                    (pop3-mailhost server)
                    (pop3-port port)
                    (pop3-authentication-scheme
-                    (if (eq authentication 'apop) 'apop 'pass)))
+                    (if (eq authentication 'apop) 'apop 'pass))
+                   (pop3-stream-type stream))
                (if (or debug-on-quit debug-on-error)
                    (save-excursion (pop3-movemail mail-source-crash-box))
                  (condition-case err
@@ -773,7 +795,8 @@
              (mail-source-run-script
               postscript
               (format-spec-make ?p password ?t mail-source-crash-box
-                                ?s server ?P port ?u user))))
+                                ?s server ?P port ?u user))
+             (mail-source-delete-crash-box)))
        ;; We nix out the password in case the error
        ;; was because of a wrong password being given.
        (setq mail-source-password-cache
@@ -865,11 +888,6 @@
 (defvar mail-source-report-new-mail-timer nil)
 (defvar mail-source-report-new-mail-idle-timer nil)
 
-(eval-when-compile
-  (if (featurep 'xemacs)
-      (require 'timer-funcs)
-    (require 'timer)))
-
 (defun mail-source-start-idle-timer ()
   ;; Start our idle timer if necessary, so we delay the check until the
   ;; user isn't typing.
@@ -912,7 +930,7 @@
          (setq display-time-mail-function #'mail-source-new-mail-p)
          ;; Set up the main timer.
          (setq mail-source-report-new-mail-timer
-               (nnheader-run-at-time
+               (run-at-time
                 (* 60 mail-source-report-new-mail-interval)
                 (* 60 mail-source-report-new-mail-interval)
                 #'mail-source-start-idle-timer))
@@ -957,7 +975,8 @@
                                  ;; MMDF mail format
                                  (insert "\001\001\001\001\n"))
                                (delete-file file)))))
-             (incf found (mail-source-callback callback file))))))
+             (incf found (mail-source-callback callback file))
+             (mail-source-delete-crash-box)))))
       found)))
 
 (eval-and-compile
@@ -1018,11 +1037,13 @@
                  (insert "From imap " (current-time-string) "\n")
                  (save-excursion
                    (insert str "\n\n"))
-                 (while (re-search-forward "^From " nil t)
+                 (while (let ((case-fold-search nil))
+                          (re-search-forward "^From " nil t))
                    (replace-match ">From "))
                  (goto-char (point-max))))
              (nnheader-ms-strip-cr))
            (incf found (mail-source-callback callback server))
+           (mail-source-delete-crash-box)
            (when (and remove fetchflag)
              (setq remove (nreverse remove))
              (imap-message-flags-add
@@ -1068,7 +1089,8 @@
          (push (cons (format "webmail:%s:%s" subtype user) password)
                mail-source-password-cache)))
       (webmail-fetch mail-source-crash-box subtype user password)
-      (mail-source-callback callback (symbol-name subtype)))))
+      (mail-source-callback callback (symbol-name subtype))
+      (mail-source-delete-crash-box))))
 
 (provide 'mail-source)
 




reply via email to

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