From: dmaus Date: Thu, 2 Jun 2011 11:46:59 +0000 (+0000) Subject: Return uid of append message if requested X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2e37e3f9b32965e60dace5ef46b190ef822f945;p=elisp%2Fwanderlust.git Return uid of append message if requested * elmo-date.el (elmo-time-make-imap-date-string): New function. Return IMAP4 compliant date string. * elmo-imap4.el (elmo-folder-append-buffer): Return uid of append message if requested. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 597f7ec..ebe1eef 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,11 @@ +2011-06-02 David Maus + + * elmo-date.el (elmo-time-make-imap-date-string): New + function. Return IMAP4 compliant date string. + + * elmo-imap4.el (elmo-folder-append-buffer): Return uid of append + message if requested. + 2011-05-29 David Maus * elmo-maildir.el (elmo-folder-append-buffer): Return number of diff --git a/elmo/elmo-date.el b/elmo/elmo-date.el index 7d986ea..f51873f 100644 --- a/elmo/elmo-date.el +++ b/elmo/elmo-date.el @@ -224,6 +224,10 @@ Otherwise treat \\ in NEWTEXT string as special: (let ((system-time-locale "C")) (format-time-string "%a, %d %b %Y %T %z" time))) +(defun elmo-time-make-imap-date-string (time) + (let ((system-time-locale "C")) + (format-time-string "%d-%b-%Y %T %z"))) + (defun elmo-time-less-p (lhs rhs) (while (and (car lhs) (car rhs)) (cond ((< (car lhs) (car rhs)) diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index 9feda9e..d040a61 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -2718,6 +2718,7 @@ If optional argument REMOVE is non-nil, remove FLAG." ((folder elmo-imap4-folder) &optional flags number return-number) (if (elmo-folder-plugged-p folder) (let ((session (elmo-imap4-get-session folder)) + (internaldate (elmo-time-make-imap-date-string (current-time))) send-buffer result) (elmo-imap4-session-select-mailbox session (elmo-imap4-folder-mailbox-internal @@ -2734,11 +2735,42 @@ If optional argument REMOVE is non-nil, remove FLAG." (if (and flags (elmo-folder-use-flag-p folder)) (concat " (" (elmo-imap4-flags-to-imap flags) ") ") " () ") + (if return-number + (concat " \"" internaldate "\" ") + "") (elmo-imap4-buffer-literal send-buffer)))) (kill-buffer send-buffer)) (when result (elmo-folder-preserve-flags - folder (elmo-msgdb-get-message-id-from-buffer) flags)) + folder (elmo-msgdb-get-message-id-from-buffer) flags) + (when return-number + (unless (setq result (cadadr (assq 'appenduid (cdar result)))) + (let ((candidates + (elmo-imap4-response-value + (elmo-imap4-send-command-wait + session + (list + "uid search since " + (car (split-string internaldate " ")))) 'search))) + (if (null candidates) + (setq result t) + (setq candidates + (elmo-imap4-response-value-all + (elmo-imap4-send-command-wait + session + (list + "uid fetch " + (mapconcat 'number-to-string candidates ",") + " (internaldate)")) 'fetch)) + (while candidates + (if (string= (cadar candidates) internaldate) + (setq result (cons + (cadadr candidates) + result))) + (setq candidates (cddr candidates))) + (setq result (or (null result) + (> (length result) 1) + (car result)))))))) result) ;; Unplugged (if elmo-enable-disconnected-operation