1 ;;; elmo-pop3.el -- POP3 Interface for ELMO.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 1999,2000 Kenichi OKADA <okada@opaopa.org>
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;; Kenichi OKADA <okada@opaopa.org>
8 ;; Keywords: mail, net news
10 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
41 (autoload 'md5 "md5"))
43 (defvar elmo-pop3-exists-exactly t)
44 (defvar sasl-mechanism-alist)
46 (defvar elmo-pop3-total-size nil)
48 (luna-define-class elmo-pop3-session (elmo-network-session))
51 (defvar elmo-pop3-read-point nil)
52 (defvar elmo-pop3-number-uidl-hash nil) ; number -> uidl
53 (defvar elmo-pop3-uidl-number-hash nil) ; uidl -> number
54 (defvar elmo-pop3-size-hash nil) ; number -> size
55 (defvar elmo-pop3-uidl-done nil)
56 (defvar elmo-pop3-list-done nil)
57 (defvar elmo-pop3-lock nil)
59 (defvar elmo-pop3-local-variables '(elmo-pop3-read-point
60 elmo-pop3-uidl-number-hash
61 elmo-pop3-number-uidl-hash
67 (luna-define-method elmo-network-close-session ((session elmo-pop3-session))
68 (when (elmo-network-session-process-internal session)
69 (when (memq (process-status
70 (elmo-network-session-process-internal session))
72 (elmo-pop3-send-command (elmo-network-session-process-internal session)
74 (or (elmo-pop3-read-response
75 (elmo-network-session-process-internal session) t)
76 (error "POP error: QUIT failed")))
77 (kill-buffer (process-buffer
78 (elmo-network-session-process-internal session)))
79 (delete-process (elmo-network-session-process-internal session))))
81 (defun elmo-pop3-get-session (spec &optional if-exists)
82 (elmo-network-get-session
85 (elmo-pop3-spec-hostname spec)
86 (elmo-pop3-spec-port spec)
87 (elmo-pop3-spec-username spec)
88 (elmo-pop3-spec-auth spec)
89 (elmo-pop3-spec-stream-type spec)
92 (defun elmo-pop3-send-command (process command &optional no-erase)
93 (with-current-buffer (process-buffer process)
96 (goto-char (point-min))
97 (setq elmo-pop3-read-point (point))
99 (process-send-string process command)
100 (process-send-string process "\r\n")))
102 (defun elmo-pop3-read-response (process &optional not-command)
103 (with-current-buffer (process-buffer process)
104 (let ((case-fold-search nil)
105 (response-string nil)
106 (response-continue t)
109 (while response-continue
110 (goto-char elmo-pop3-read-point)
111 (while (not (re-search-forward "\r?\n" nil t))
112 (accept-process-output process)
113 (goto-char elmo-pop3-read-point))
114 (setq match-end (point))
115 (setq response-string
116 (buffer-substring elmo-pop3-read-point (- match-end 2)))
117 (goto-char elmo-pop3-read-point)
118 (if (looking-at "\\+.*$")
120 (setq response-continue nil)
121 (setq elmo-pop3-read-point match-end)
124 (concat return-value "\n" response-string)
126 (if (looking-at "\\-.*$")
128 (setq response-continue nil)
129 (setq elmo-pop3-read-point match-end)
130 (setq return-value nil))
131 (setq elmo-pop3-read-point match-end)
133 (setq response-continue nil))
136 (concat return-value "\n" response-string)
138 (setq elmo-pop3-read-point match-end)))
142 (defun elmo-pop3-process-filter (process output)
144 (set-buffer (process-buffer process))
145 (goto-char (point-max))
147 (if elmo-pop3-total-size
148 (message "Retrieving...(%d/%d bytes)."
149 (buffer-size) elmo-pop3-total-size))))
151 (defun elmo-pop3-auth-user (session)
152 (let ((process (elmo-network-session-process-internal session)))
154 (elmo-pop3-send-command
156 (format "user %s" (elmo-network-session-user-internal session)))
157 (or (elmo-pop3-read-response process t)
158 (signal 'elmo-authenticate-error
159 '(elmo-pop-auth-user)))
160 (elmo-pop3-send-command process
164 (elmo-network-session-password-key session))))
165 (or (elmo-pop3-read-response process t)
166 (signal 'elmo-authenticate-error
167 '(elmo-pop-auth-user)))))
169 (defun elmo-pop3-auth-apop (session)
170 (if (string-match "^\+OK .*\\(<[^\>]+>\\)"
171 (elmo-network-session-greeting-internal session))
172 ;; good, APOP ready server
174 (elmo-pop3-send-command
175 (elmo-network-session-process-internal session)
177 (elmo-network-session-user-internal session)
179 (concat (match-string
181 (elmo-network-session-greeting-internal session))
183 (elmo-network-session-password-key session))))))
184 (or (elmo-pop3-read-response
185 (elmo-network-session-process-internal session)
187 (signal 'elmo-authenticate-error
188 '(elmo-pop3-auth-apop))))
189 (signal 'elmo-open-error '(elmo-pop3-auth-apop))))
191 (luna-define-method elmo-network-initialize-session-buffer :after
192 ((session elmo-pop3-session) buffer)
193 (with-current-buffer buffer
194 (mapcar 'make-variable-buffer-local elmo-pop3-local-variables)))
196 (luna-define-method elmo-network-initialize-session ((session
198 (let ((process (elmo-network-session-process-internal session))
200 (with-current-buffer (process-buffer process)
201 (set-process-filter process 'elmo-pop3-process-filter)
202 (setq elmo-pop3-read-point (point-min))
203 ;; Skip garbage output from process before greeting.
204 (while (and (memq (process-status process) '(open run))
205 (goto-char (point-max))
207 (not (looking-at "+OK")))
208 (accept-process-output process 1))
209 (setq elmo-pop3-read-point (point))
210 (or (elmo-network-session-set-greeting-internal
212 (elmo-pop3-read-response process t))
213 (signal 'elmo-open-error
214 '(elmo-network-intialize-session)))
215 (when (eq (elmo-network-stream-type-symbol
216 (elmo-network-session-stream-type-internal session))
218 (elmo-pop3-send-command process "stls")
219 (if (string-match "^\+OK"
220 (elmo-pop3-read-response process))
221 (starttls-negotiate process)
222 (signal 'elmo-open-error
223 '(elmo-pop3-starttls-error)))))))
225 (luna-define-method elmo-network-authenticate-session ((session
227 (with-current-buffer (process-buffer
228 (elmo-network-session-process-internal session))
229 (let* ((process (elmo-network-session-process-internal session))
230 (auth (elmo-network-session-auth-internal session))
231 (auth (mapcar '(lambda (mechanism) (upcase (symbol-name mechanism)))
232 (if (listp auth) auth (list auth))))
234 client name step response mechanism
235 sasl-read-passphrase)
236 (or (and (string= "USER" (car auth))
237 (elmo-pop3-auth-user session))
238 (and (string= "APOP" (car auth))
239 (elmo-pop3-auth-apop session))
242 (setq sasl-mechanisms (mapcar 'car sasl-mechanism-alist))
243 (setq mechanism (sasl-find-mechanism auth))
245 (signal 'elmo-authenticate-error '(elmo-pop3-auth-no-mechanisms)))
249 (elmo-network-session-user-internal session)
251 (elmo-network-session-host-internal session)))
252 ;;; (if elmo-pop3-auth-user-realm
253 ;;; (sasl-client-set-property client 'realm elmo-pop3-auth-user-realm))
254 (setq name (sasl-mechanism-name mechanism))
255 (elmo-network-session-set-auth-internal session
256 (intern (downcase name)))
257 (setq sasl-read-passphrase
261 (elmo-network-session-password-key session)))))
262 (setq step (sasl-next-step client nil))
263 (elmo-pop3-send-command
266 (and (sasl-step-data step)
269 (elmo-base64-encode-string
270 (sasl-step-data step) 'no-line-break))))) ;)
273 (unless (setq response (elmo-pop3-read-response process t))
274 ;; response is NO or BAD.
275 (signal 'elmo-authenticate-error
277 (concat "elmo-pop3-auth-"
279 (if (string-match "^\+OK" response)
280 (if (sasl-next-step client step)
282 (signal 'elmo-authenticate-error
284 (concat "elmo-pop3-auth-"
286 ;; The authentication process is finished.
290 (elmo-base64-decode-string
291 (cadr (split-string response " "))))
292 (setq step (sasl-next-step client step))
293 (elmo-pop3-send-command
295 (if (sasl-step-data step)
296 (elmo-base64-encode-string (sasl-step-data step)
300 (luna-define-method elmo-network-setup-session ((session
302 (let ((process (elmo-network-session-process-internal session))
304 (with-current-buffer (process-buffer process)
305 (setq elmo-pop3-size-hash (elmo-make-hash 31))
306 ;; To get obarray of uidl and size
307 (elmo-pop3-send-command process "list")
308 (if (null (elmo-pop3-read-response process))
309 (error "POP LIST command failed"))
310 (if (null (setq response
311 (elmo-pop3-read-contents
312 (current-buffer) process)))
313 (error "POP LIST command failed"))
314 ;; POP server always returns a sequence of serial numbers.
315 (setq count (elmo-pop3-parse-list-response response))
317 (when elmo-pop3-use-uidl
318 (setq elmo-pop3-uidl-number-hash (elmo-make-hash (* count 2)))
319 (setq elmo-pop3-number-uidl-hash (elmo-make-hash (* count 2)))
321 (elmo-pop3-send-command process "uidl")
322 (unless (elmo-pop3-read-response process)
323 (error "POP UIDL failed"))
324 (unless (setq response (elmo-pop3-read-contents
325 (current-buffer) process))
326 (error "POP UIDL failed"))
327 (elmo-pop3-parse-uidl-response response)))))
329 (defun elmo-pop3-read-contents (buffer process)
330 (with-current-buffer buffer
331 (let ((case-fold-search nil)
333 (goto-char elmo-pop3-read-point)
334 (while (not (re-search-forward "^\\.\r\n" nil t))
335 (accept-process-output process)
336 (goto-char elmo-pop3-read-point))
337 (setq match-end (point))
340 (buffer-substring elmo-pop3-read-point
344 (defun elmo-pop3-list-folders (spec &optional hierarchy) nil)
345 (defun elmo-pop3-append-msg (spec string) nil nil)
346 (defun elmo-pop3-folder-creatable-p (spec) nil)
347 (defun elmo-pop3-create-folder (spec) nil)
349 (defun elmo-pop3-folder-exists-p (spec)
350 (if (and elmo-pop3-exists-exactly
351 (elmo-pop3-plugged-p spec))
353 (let (elmo-auto-change-plugged ; don't change plug status.
354 elmo-pop3-use-uidl ; No need to use uidl.
357 (setq session (elmo-pop3-get-session spec))
359 (elmo-network-close-session session)))))
362 (defun elmo-pop3-parse-uidl-response (string)
363 (let ((buffer (current-buffer))
366 (let (number uid list)
368 (goto-char (point-min))
369 (while (re-search-forward "^\\([0-9]+\\)[\t ]\\([^ \n]+\\)$" nil t)
370 (setq number (elmo-match-buffer 1))
371 (setq uid (elmo-match-buffer 2))
372 (with-current-buffer buffer
373 (elmo-set-hash-val uid number elmo-pop3-uidl-number-hash)
374 (elmo-set-hash-val (concat "#" number) uid
375 elmo-pop3-number-uidl-hash))
376 (setq list (cons uid list)))
377 (with-current-buffer buffer (setq elmo-pop3-uidl-done t))
380 (defun elmo-pop3-parse-list-response (string)
381 (let ((buffer (current-buffer))
386 (goto-char (point-min))
387 (while (re-search-forward "^\\([0-9]+\\)[\t ]\\([0-9]+\\)$" nil t)
390 (cons (elmo-match-buffer 1)
391 (elmo-match-buffer 2))
393 (setq count (1+ count)))
394 (with-current-buffer buffer
395 (setq elmo-pop3-size-hash (elmo-make-hash (* (length alist) 2)))
397 (elmo-set-hash-val (concat "#" (car (car alist)))
400 (setq alist (cdr alist)))
401 (setq elmo-pop3-list-done t))
404 (defun elmo-pop3-list-location (spec)
405 (with-current-buffer (process-buffer
406 (elmo-network-session-process-internal
407 (elmo-pop3-get-session spec)))
409 (if elmo-pop3-uidl-done
413 (setq list (cons (symbol-name atom) list)))
414 elmo-pop3-uidl-number-hash)
416 (error "POP3: Error in UIDL")))))
418 (defun elmo-pop3-list-by-uidl-subr (spec &optional nonsort)
419 (let ((flist (elmo-list-folder-by-location
421 (elmo-pop3-list-location spec))))
423 (cons (elmo-max-of-list flist) (length flist))
426 (defun elmo-pop3-list-by-list (spec)
427 (with-current-buffer (process-buffer
428 (elmo-network-session-process-internal
429 (elmo-pop3-get-session spec)))
431 (if elmo-pop3-list-done
433 (mapatoms (lambda (atom)
434 (setq list (cons (string-to-int
435 (substring (symbol-name atom) 1))
439 (error "POP3: Error in list")))))
441 (defun elmo-pop3-list-folder (spec &optional nohide)
442 (let ((killed (and elmo-use-killed-list
443 (elmo-msgdb-killed-list-load
444 (elmo-msgdb-expand-path spec))))
446 (elmo-pop3-commit spec)
447 (setq numbers (if elmo-pop3-use-uidl
449 (elmo-pop3-list-by-uidl-subr spec))
450 (elmo-pop3-list-by-list spec)))
451 (elmo-living-messages numbers killed)))
453 (defun elmo-pop3-max-of-folder (spec)
454 (elmo-pop3-commit spec)
455 (if elmo-pop3-use-uidl
456 (elmo-pop3-list-by-uidl-subr spec 'nonsort)
458 (elmo-network-session-process-internal
459 (elmo-pop3-get-session spec)))
462 (with-current-buffer (process-buffer process)
463 (elmo-pop3-send-command process "STAT")
464 (setq response (elmo-pop3-read-response process))
465 ;; response: "^\+OK 2 7570$"
466 (if (not (string-match "^\+OK[ \t]*\\([0-9]*\\)" response))
467 (error "POP STAT command failed")
470 (substring response (match-beginning 1)(match-end 1 ))))
471 (cons total total))))))
473 (defvar elmo-pop3-header-fetch-chop-length 200)
475 (defsubst elmo-pop3-next-result-arrived-p ()
477 ((eq (following-char) ?+)
478 (if (re-search-forward "\n\\.\r?\n" nil t)
482 (if (search-forward "\n" nil t)
488 (defun elmo-pop3-lock ()
490 (setq elmo-pop3-lock t))
492 (defun elmo-pop3-unlock ()
493 "Unlock pop3 process."
494 (setq elmo-pop3-lock nil))
496 (defun elmo-pop3-locked-p (process)
497 "Return t if pop3 PROCESS is locked."
498 (with-current-buffer (process-buffer process)
501 (defun elmo-pop3-retrieve-headers (buffer tobuffer process articles)
505 (let ((number (length articles))
508 (last-point (point-min)))
509 ;; Send HEAD commands.
511 (elmo-pop3-send-command process (format
512 "top %s 0" (car articles))
514 ;;; (accept-process-output process 1)
515 (setq articles (cdr articles))
516 (setq count (1+ count))
517 ;; Every 200 requests we have to read the stream in
518 ;; order to avoid deadlocks.
519 (when (or elmo-pop3-send-command-synchronously
520 (null articles) ;All requests have been sent.
521 (zerop (% count elmo-pop3-header-fetch-chop-length)))
522 (unless elmo-pop3-send-command-synchronously
523 (accept-process-output process 1))
527 (goto-char last-point)
529 (while (elmo-pop3-next-result-arrived-p)
530 (setq last-point (point))
531 (setq received (1+ received)))
533 (when (> number elmo-display-progress-threshold)
534 (if (or (zerop (% received 5)) (= received number))
535 (elmo-display-progress
536 'elmo-pop3-retrieve-headers "Getting headers..."
537 (/ (* received 100) number))))
538 (accept-process-output process 1)
539 ;;; (accept-process-output process)
541 ;; Remove all "\r"'s.
542 (goto-char (point-min))
543 (while (search-forward "\r\n" nil t)
544 (replace-match "\n"))
545 (copy-to-buffer tobuffer (point-min) (point-max)))))
547 (defalias 'elmo-pop3-msgdb-create 'elmo-pop3-msgdb-create-as-numlist)
549 (defun elmo-pop3-sort-overview-by-original-number (overview loc-alist)
553 (< (elmo-pop3-uidl-to-number
554 (cdr (assq (elmo-msgdb-overview-entity-get-number ent1)
556 (elmo-pop3-uidl-to-number
557 (cdr (assq (elmo-msgdb-overview-entity-get-number ent2)
561 (defun elmo-pop3-sort-msgdb-by-original-number (msgdb)
562 (message "Sorting...")
563 (let ((overview (elmo-msgdb-get-overview msgdb)))
564 (setq overview (elmo-pop3-sort-overview-by-original-number
566 (elmo-msgdb-get-location msgdb)))
567 (message "Sorting...done")
568 (list overview (nth 1 msgdb)(nth 2 msgdb)(nth 3 msgdb)(nth 4 msgdb))))
570 (defun elmo-pop3-msgdb-create-as-numlist (spec numlist new-mark
571 already-mark seen-mark
572 important-mark seen-list
575 (let ((process (elmo-network-session-process-internal
576 (elmo-pop3-get-session spec)))
578 (if elmo-pop3-use-uidl
579 (setq loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
580 (elmo-msgdb-location-load
581 (elmo-msgdb-expand-path spec)))))
582 (with-current-buffer (process-buffer process)
583 (elmo-pop3-sort-msgdb-by-original-number
584 (elmo-pop3-msgdb-create-by-header process numlist
585 new-mark already-mark
589 (defun elmo-pop3-uidl-to-number (uidl)
590 (string-to-number (elmo-get-hash-val uidl
591 elmo-pop3-uidl-number-hash)))
593 (defun elmo-pop3-number-to-uidl (number)
594 (elmo-get-hash-val (format "#%d" number)
595 elmo-pop3-number-uidl-hash))
597 (defun elmo-pop3-number-to-size (number)
598 (elmo-get-hash-val (format "#%d" number)
599 elmo-pop3-size-hash))
601 (defun elmo-pop3-msgdb-create-by-header (process numlist
602 new-mark already-mark
606 (let ((tmp-buffer (get-buffer-create " *ELMO Overview TMP*")))
607 (with-current-buffer (process-buffer process)
608 (if loc-alist ; use uidl.
614 (elmo-pop3-uidl-to-number (cdr (assq number loc-alist))))
616 (elmo-pop3-retrieve-headers (process-buffer process)
617 tmp-buffer process numlist)
619 (elmo-pop3-msgdb-create-message
624 new-mark already-mark seen-mark seen-list loc-alist)
625 (kill-buffer tmp-buffer)))))
627 (defun elmo-pop3-msgdb-create-message (buffer
630 numlist new-mark already-mark
635 (let (beg overview number-alist mark-alist
636 entity i number message-id gmark seen size)
638 (elmo-set-buffer-multibyte default-enable-multibyte-characters)
639 (goto-char (point-min))
641 (message "Creating msgdb...")
643 (setq beg (save-excursion (forward-line 1) (point)))
644 (elmo-pop3-next-result-arrived-p)
648 (narrow-to-region beg (point))
650 (elmo-msgdb-create-overview-from-buffer
652 (setq numlist (cdr numlist))
655 (elmo-msgdb-append-element
657 (with-current-buffer (process-buffer process)
658 (elmo-msgdb-overview-entity-set-size
661 (elmo-pop3-number-to-size
662 (elmo-msgdb-overview-entity-get-number entity))))
666 (elmo-pop3-number-to-uidl
667 (elmo-msgdb-overview-entity-get-number entity))
669 (elmo-msgdb-overview-entity-set-number entity number)))
671 (elmo-msgdb-number-add
673 (elmo-msgdb-overview-entity-get-number entity)
675 (setq message-id (car entity))
676 (setq seen (member message-id seen-list))
677 (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
678 (if (elmo-cache-exists-p
684 (if elmo-pop3-use-cache
688 (elmo-msgdb-mark-append
690 (elmo-msgdb-overview-entity-get-number entity)
692 (when (> num elmo-display-progress-threshold)
694 (if (or (zerop (% i 5)) (= i num))
695 (elmo-display-progress
696 'elmo-pop3-msgdb-create-message "Creating msgdb..."
697 (/ (* i 100) num)))))
698 (list overview number-alist mark-alist loc-alist))))
700 (defun elmo-pop3-read-body (process outbuf)
701 (with-current-buffer (process-buffer process)
702 (let ((start elmo-pop3-read-point)
705 (while (not (re-search-forward "^\\.\r?\n" nil t))
706 (accept-process-output process)
709 (with-current-buffer outbuf
711 (insert-buffer-substring (process-buffer process) start (- end 3))
712 (elmo-delete-cr-get-content-type)))))
714 (defun elmo-pop3-read-msg (spec number outbuf &optional msgdb unread)
715 (let* ((loc-alist (if elmo-pop3-use-uidl
717 (elmo-msgdb-get-location msgdb)
718 (elmo-msgdb-location-load
719 (elmo-msgdb-expand-path spec)))))
720 (process (elmo-network-session-process-internal
721 (elmo-pop3-get-session spec)))
722 size response errmsg msg)
723 (with-current-buffer (process-buffer process)
725 (setq number (elmo-pop3-uidl-to-number
726 (cdr (assq number loc-alist)))))
727 (setq size (string-to-number
728 (elmo-pop3-number-to-size number)))
730 (elmo-pop3-send-command process
731 (format "retr %s" number))
732 (setq elmo-pop3-total-size size)
733 (unless elmo-inhibit-display-retrieval-progress
734 (setq elmo-pop3-total-size size)
735 (elmo-display-progress
736 'elmo-pop3-display-retrieval-progress
737 (format "Retrieving (0/%d bytes)..." elmo-pop3-total-size)
741 (when (null (setq response (elmo-pop3-read-response
743 (error "Fetching message failed"))
744 (setq response (elmo-pop3-read-body process outbuf)))
745 (setq elmo-pop3-total-size nil))
746 (unless elmo-inhibit-display-retrieval-progress
747 (elmo-display-progress
748 'elmo-display-retrieval-progress "" 100) ; remove progress bar.
749 (message "Retrieving...done."))
751 (goto-char (point-min))
752 (while (re-search-forward "^\\." nil t)
757 (defun elmo-pop3-delete-msg (process number loc-alist)
758 (with-current-buffer (process-buffer process)
759 (let (response errmsg msg)
761 (setq number (elmo-pop3-uidl-to-number
762 (cdr (assq number loc-alist)))))
765 (elmo-pop3-send-command process
766 (format "dele %s" number))
767 (when (null (setq response (elmo-pop3-read-response
769 (error "Deleting message failed")))
770 (error "Deleting message failed")))))
772 (defun elmo-pop3-delete-msgs (spec msgs &optional msgdb)
773 (let ((loc-alist (if elmo-pop3-use-uidl
775 (elmo-msgdb-get-location msgdb)
776 (elmo-msgdb-location-load
777 (elmo-msgdb-expand-path spec)))))
778 (process (elmo-network-session-process-internal
779 (elmo-pop3-get-session spec))))
780 (mapcar '(lambda (msg) (elmo-pop3-delete-msg
781 process msg loc-alist))
784 (defun elmo-pop3-search (spec condition &optional numlist)
785 (error "Searching in pop3 folder is not implemented yet"))
787 (defun elmo-pop3-use-cache-p (spec number)
790 (defun elmo-pop3-local-file-p (spec number)
793 (defun elmo-pop3-port-label (spec)
795 (if (elmo-pop3-spec-stream-type spec)
796 (concat "!" (symbol-name
797 (elmo-network-stream-type-symbol
798 (elmo-pop3-spec-stream-type spec)))))))
800 (defsubst elmo-pop3-portinfo (spec)
801 (list (elmo-pop3-spec-hostname spec)
802 (elmo-pop3-spec-port spec)))
804 (defun elmo-pop3-plugged-p (spec)
805 (apply 'elmo-plugged-p
806 (append (elmo-pop3-portinfo spec)
807 (list nil (quote (elmo-pop3-port-label spec))))))
809 (defun elmo-pop3-set-plugged (spec plugged add)
810 (apply 'elmo-set-plugged plugged
811 (append (elmo-pop3-portinfo spec)
812 (list nil nil (quote (elmo-pop3-port-label spec)) add))))
814 (defalias 'elmo-pop3-sync-number-alist
815 'elmo-generic-sync-number-alist)
816 (defalias 'elmo-pop3-list-folder-unread
817 'elmo-generic-list-folder-unread)
818 (defalias 'elmo-pop3-list-folder-important
819 'elmo-generic-list-folder-important)
820 (defalias 'elmo-pop3-folder-diff 'elmo-generic-folder-diff)
822 (defun elmo-pop3-commit (spec)
823 (if (elmo-pop3-plugged-p spec)
824 (let ((session (elmo-pop3-get-session spec 'if-exists)))
826 (not (elmo-pop3-locked-p
827 (elmo-network-session-process-internal session))))
828 (elmo-network-close-session session)))))
832 (product-provide (provide 'elmo-pop3) (require 'elmo-version))
834 ;;; elmo-pop3.el ends here