(require 'cl)
(autoload 'open-ssl-stream "ssl")
(autoload 'base64-decode-string "base64")
+ (autoload 'base64-encode-string "mel")
(autoload 'rfc2104-hash "rfc2104")
(autoload 'md5 "md5")
(autoload 'utf7-encode "utf7")
(defconst imap-default-port 143)
(defconst imap-default-ssl-port 993)
(defconst imap-default-stream 'network)
-(defconst imap-coding-system-for-read 'binary)
-(defconst imap-coding-system-for-write 'binary)
(defconst imap-local-variables '(imap-server
imap-port
imap-client-eol
\f
;; Utility functions:
-(defsubst imap-disable-multibyte ()
- "Enable multibyte in the current buffer."
- (when (fboundp 'set-buffer-multibyte)
- (set-buffer-multibyte nil)))
-
(defun imap-read-passwd (prompt &rest args)
"Read a password using PROMPT. If ARGS, PROMPT is used as an
argument to `format'."
(defun imap-kerberos4-open (name buffer server port)
(message "Opening Kerberized IMAP connection...")
(let* ((port (or port imap-default-port))
- (coding-system-for-read imap-coding-system-for-read)
- (coding-system-for-write imap-coding-system-for-write)
- (process (start-process
- name buffer shell-file-name shell-command-switch
- (format-spec
- imap-imtest-program
- (format-spec-make ?s server ?p (number-to-string port))))))
+ (process (as-binary-process
+ (start-process
+ name buffer shell-file-name shell-command-switch
+ (format-spec
+ imap-imtest-program
+ (format-spec-make ?s server ?p (number-to-string port))
+ )))))
(when process
(with-current-buffer buffer
(setq imap-client-eol "\n")
(sit-for 1))
(and imap-log
(with-current-buffer (get-buffer-create imap-log)
- (imap-disable-multibyte)
(buffer-disable-undo)
(goto-char (point-max))
(insert-buffer-substring buffer)))
(defun imap-ssl-open-2 (name buffer server port &optional extra-ssl-args)
(let* ((port (or port imap-default-ssl-port))
- (coding-system-for-read imap-coding-system-for-read)
- (coding-system-for-write imap-coding-system-for-write)
(ssl-program-name imap-ssl-program)
(ssl-program-arguments (append imap-ssl-arguments extra-ssl-args
(list "-connect"
(format "%s:%d" server port))))
(process (ignore-errors (open-ssl-stream name buffer server port))))
(when process
+ (set-process-coding-system process 'binary 'binary)
(with-current-buffer buffer
(goto-char (point-min))
(while (and (memq (process-status process) '(open run))
(sit-for 1))
(and imap-log
(with-current-buffer (get-buffer-create imap-log)
- (imap-disable-multibyte)
(buffer-disable-undo)
(goto-char (point-max))
(insert-buffer-substring buffer)))
(defun imap-network-open (name buffer server port)
(let* ((port (or port imap-default-port))
- (coding-system-for-read imap-coding-system-for-read)
- (coding-system-for-write imap-coding-system-for-write)
- (process (open-network-stream name buffer server port)))
+ (process (open-network-stream-as-binary name buffer server port)))
(when process
(while (and (memq (process-status process) '(open run))
(goto-char (point-min))
(sit-for 1))
(and imap-log
(with-current-buffer (get-buffer-create imap-log)
- (imap-disable-multibyte)
(buffer-disable-undo)
(goto-char (point-max))
(insert-buffer-substring buffer)))
(if (imap-opened buffer)
(imap-close buffer))
(mapc 'make-variable-buffer-local imap-local-variables)
- (imap-disable-multibyte)
(buffer-disable-undo)
(setq imap-server (or server imap-server))
(setq imap-port (or port imap-port))
(setq cmdstr (concat cmdstr imap-client-eol))
(and imap-log
(with-current-buffer (get-buffer-create imap-log)
- (imap-disable-multibyte)
(buffer-disable-undo)
(goto-char (point-max))
(insert cmdstr)))
(and imap-log
(with-current-buffer (get-buffer-create
imap-log)
- (imap-disable-multibyte)
(buffer-disable-undo)
(goto-char (point-max))
(insert-buffer-substring cmd)))
(insert string)
(and imap-log
(with-current-buffer (get-buffer-create imap-log)
- (imap-disable-multibyte)
(buffer-disable-undo)
(goto-char (point-max))
(insert string)))
(defsubst imap-parse-string ()
(let (strstart strend)
- (cond ((and (eq (char-after) ?\")
+ (cond ((and (eq (char-after (point)) ?\")
(setq strstart (point))
(setq strend (search-forward "\"" nil t 2)))
(buffer-substring-no-properties (1+ strstart) (1- strend)))
(require 'nnoo)
(require 'nnmail)
(require 'nnheader)
-(require 'mm-util)
(require 'gnus)
(require 'gnus-async)
(require 'gnus-range)
(with-current-buffer nntp-server-buffer
(nnheader-insert-nov
(with-current-buffer nnimap-server-buffer
- (vector imap-current-message
- (nnimap-replace-whitespace
- (imap-message-envelope-subject imap-current-message))
- (nnimap-replace-whitespace
- (imap-envelope-from
- (car-safe (imap-message-envelope-from
- imap-current-message))))
- (nnimap-replace-whitespace
- (imap-message-envelope-date imap-current-message))
- (nnimap-replace-whitespace
- (imap-message-envelope-message-id imap-current-message))
- (nnimap-replace-whitespace
- (let ((str (if (imap-capability 'IMAP4rev1)
- (nth 2 (assoc
- "HEADER.FIELDS REFERENCES"
- (imap-message-get
- imap-current-message 'BODYDETAIL)))
- (imap-message-get imap-current-message
- 'RFC822.HEADER))))
- (if (> (length str) (length "References: "))
- (substring str (length "References: "))
- (if (and (setq str (imap-message-envelope-in-reply-to
- imap-current-message))
- (string-match "<[^>]+>" str))
- (substring str (match-beginning 0) (match-end 0))))))
- (imap-message-get imap-current-message 'RFC822.SIZE)
- (imap-body-lines (imap-message-body imap-current-message))
- nil ;; xref
- nil))))) ;; extra-headers
+ (make-full-mail-header
+ imap-current-message
+ (or (nnimap-replace-whitespace
+ (imap-message-envelope-subject imap-current-message))
+ "(none)")
+ (nnimap-replace-whitespace
+ (imap-envelope-from
+ (car-safe (imap-message-envelope-from
+ imap-current-message))))
+ (nnimap-replace-whitespace
+ (imap-message-envelope-date imap-current-message))
+ (nnimap-replace-whitespace
+ (imap-message-envelope-message-id imap-current-message))
+ (nnimap-replace-whitespace
+ (let ((str (if (imap-capability 'IMAP4rev1)
+ (nth 2 (assoc
+ "HEADER.FIELDS REFERENCES"
+ (imap-message-get
+ imap-current-message 'BODYDETAIL)))
+ (imap-message-get imap-current-message
+ 'RFC822.HEADER))))
+ (if (> (length str) (length "References: "))
+ (substring str (length "References: "))
+ (if (and (setq str (imap-message-envelope-in-reply-to
+ imap-current-message))
+ (string-match "<[^>]+>" str))
+ (substring str (match-beginning 0) (match-end 0))))))
+ (imap-message-get imap-current-message 'RFC822.SIZE)
+ (imap-body-lines (imap-message-body imap-current-message))
+ nil ;; xref
+ nil))))) ;; extra-headers
(defun nnimap-retrieve-which-headers (articles fetch-old)
"Get a range of articles to fetch based on ARTICLES and FETCH-OLD."
(if (or nnmail-use-long-file-names
(file-exists-p (concat dir file)))
(concat dir file)
- (concat dir (mm-encode-coding-string
+ (concat dir (encode-coding-string
(nnheader-replace-chars-in-string file ?. ?/)
nnmail-pathname-coding-system)))))
(with-current-buffer nntp-server-buffer
(let ((nov (nnimap-group-overview-filename group server)))
(when (file-exists-p nov)
- (mm-insert-file-contents nov)
+ (nnheader-insert-file-contents nov)
(set-buffer-modified-p nil)
(let ((min (progn (goto-char (point-min))
(when (not (eobp))