1 ;;; elmo-nntp.el --- NNTP Interface for ELMO.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 1998,1999,2000 Masahiro MURATA <muse@ba2.so-net.ne.jp>
5 ;; Copyright (C) 1999,2000 Kenichi OKADA <okada@opaopa.org>
7 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
8 ;; Masahiro MURATA <muse@ba2.so-net.ne.jp>
9 ;; Kenichi OKADA <okada@opaopa.org>
10 ;; Keywords: mail, net news
12 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
14 ;; This program is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; This program is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
44 (defvar elmo-nntp-overview-fetch-chop-length 200
45 "*Number of overviews to fetch in one request in nntp.")
47 (defvar elmo-nntp-use-cache t
48 "Use cache in nntp folder.")
50 (defvar elmo-nntp-max-number-precedes-list-active nil
51 "Non-nil means max number of msgdb is set as the max number of `list active'.
52 (Needed for inn 2.3 or later?).")
54 (defvar elmo-nntp-group-coding-system nil
55 "A coding system for newsgroup string.")
57 (defsubst elmo-nntp-encode-group-string (string)
58 (if elmo-nntp-group-coding-system
59 (encode-coding-string string elmo-nntp-group-coding-system)
62 (defsubst elmo-nntp-decode-group-string (string)
63 (if elmo-nntp-group-coding-system
64 (decode-coding-string string elmo-nntp-group-coding-system)
69 (luna-define-class elmo-nntp-folder (elmo-net-folder)
70 (group temp-crosses reads))
71 (luna-define-internal-accessors 'elmo-nntp-folder))
73 (luna-define-method elmo-folder-initialize :around ((folder
76 (let ((elmo-network-stream-type-alist
77 (if elmo-nntp-stream-type-alist
78 (setq elmo-network-stream-type-alist
79 (append elmo-nntp-stream-type-alist
80 elmo-network-stream-type-alist))
81 elmo-network-stream-type-alist))
83 (setq name (luna-call-next-method))
84 (setq parse (elmo-parse-token name ":"))
85 (elmo-nntp-folder-set-group-internal folder
86 (elmo-nntp-encode-group-string
88 (setq parse (elmo-parse-prefixed-element ?: (cdr parse)))
89 (elmo-net-folder-set-user-internal folder
90 (if (eq (length (car parse)) 0)
91 elmo-nntp-default-user
93 (unless (elmo-net-folder-server-internal folder)
94 (elmo-net-folder-set-server-internal folder
95 elmo-nntp-default-server))
96 (unless (elmo-net-folder-port-internal folder)
97 (elmo-net-folder-set-port-internal folder
98 elmo-nntp-default-port))
99 (unless (elmo-net-folder-stream-type-internal folder)
100 (elmo-net-folder-set-stream-type-internal
102 (elmo-get-network-stream-type
103 elmo-nntp-default-stream-type)))
106 (luna-define-method elmo-folder-expand-msgdb-path ((folder elmo-nntp-folder))
107 (convert-standard-filename
109 (elmo-nntp-folder-group-internal folder)
110 (expand-file-name (or (elmo-net-folder-server-internal folder) "nowhere")
111 (expand-file-name "nntp"
112 elmo-msgdb-directory)))))
114 (luna-define-method elmo-folder-newsgroups ((folder elmo-nntp-folder))
115 (list (elmo-nntp-folder-group-internal folder)))
119 (luna-define-class elmo-nntp-session (elmo-network-session)
121 (luna-define-internal-accessors 'elmo-nntp-session))
124 ;; internal variables
127 (defvar elmo-nntp-connection-cache nil
128 "Cache of NNTP connection.")
129 ;; buffer local variable
131 (defvar elmo-nntp-list-folders-use-cache 600
132 "*Time to cache of list folders, as the number of seconds.
133 Don't cache if nil.")
135 (defvar elmo-nntp-list-folders-cache nil)
137 (defvar elmo-nntp-groups-async nil)
138 (defvar elmo-nntp-header-fetch-chop-length 200)
140 (defvar elmo-nntp-read-point 0)
142 (defvar elmo-nntp-send-mode-reader t)
144 (defvar elmo-nntp-opened-hook nil)
146 (defvar elmo-nntp-get-folders-securely nil)
148 (defvar elmo-nntp-default-use-xover t)
150 (defvar elmo-nntp-default-use-listgroup t)
152 (defvar elmo-nntp-default-use-list-active t)
154 (defvar elmo-nntp-default-use-xhdr t)
156 (defvar elmo-nntp-server-command-alist nil)
159 (defconst elmo-nntp-server-command-index '((xover . 0)
163 (defmacro elmo-nntp-get-server-command (session)
164 (` (assoc (cons (elmo-network-session-server-internal (, session))
165 (elmo-network-session-port-internal (, session)))
166 elmo-nntp-server-command-alist)))
168 (defmacro elmo-nntp-set-server-command (session com value)
170 (unless (setq entry (cdr (elmo-nntp-get-server-command
172 (setq elmo-nntp-server-command-alist
173 (nconc elmo-nntp-server-command-alist
176 (elmo-network-session-server-internal (, session))
177 (elmo-network-session-port-internal (, session)))
180 elmo-nntp-default-use-xover
181 elmo-nntp-default-use-listgroup
182 elmo-nntp-default-use-list-active
183 elmo-nntp-default-use-xhdr)))))))
185 (cdr (assq (, com) elmo-nntp-server-command-index))
188 (defmacro elmo-nntp-xover-p (session)
189 (` (let ((entry (elmo-nntp-get-server-command (, session))))
192 (cdr (assq 'xover elmo-nntp-server-command-index)))
193 elmo-nntp-default-use-xover))))
195 (defmacro elmo-nntp-set-xover (session value)
196 (` (elmo-nntp-set-server-command (, session) 'xover (, value))))
198 (defmacro elmo-nntp-listgroup-p (session)
199 (` (let ((entry (elmo-nntp-get-server-command (, session))))
202 (cdr (assq 'listgroup elmo-nntp-server-command-index)))
203 elmo-nntp-default-use-listgroup))))
205 (defmacro elmo-nntp-set-listgroup (session value)
206 (` (elmo-nntp-set-server-command (, session) 'listgroup (, value))))
208 (defmacro elmo-nntp-list-active-p (session)
209 (` (let ((entry (elmo-nntp-get-server-command (, session))))
212 (cdr (assq 'list-active elmo-nntp-server-command-index)))
213 elmo-nntp-default-use-list-active))))
215 (defmacro elmo-nntp-set-list-active (session value)
216 (` (elmo-nntp-set-server-command (, session) 'list-active (, value))))
218 (defmacro elmo-nntp-xhdr-p (session)
219 (` (let ((entry (elmo-nntp-get-server-command (, session))))
222 (cdr (assq 'xhdr elmo-nntp-server-command-index)))
223 elmo-nntp-default-use-xhdr))))
225 (defmacro elmo-nntp-set-xhdr (session value)
226 (` (elmo-nntp-set-server-command (, session) 'xhdr (, value))))
228 (defsubst elmo-nntp-max-number-precedes-list-active-p ()
229 elmo-nntp-max-number-precedes-list-active)
231 (defsubst elmo-nntp-folder-postfix (user server port type)
233 (and user (concat ":" user))
235 (null (string= server elmo-nntp-default-server)))
238 (null (eq port elmo-nntp-default-port)))
239 (concat ":" (if (numberp port)
240 (int-to-string port) port)))
241 (unless (eq (elmo-network-stream-type-symbol type)
242 elmo-nntp-default-stream-type)
243 (elmo-network-stream-type-spec-string type))))
245 (defun elmo-nntp-get-session (folder &optional if-exists)
246 (elmo-network-get-session
249 (if (elmo-folder-biff-internal folder)
255 (luna-define-method elmo-network-initialize-session ((session
257 (let ((process (elmo-network-session-process-internal session))
259 (set-process-filter (elmo-network-session-process-internal session)
260 'elmo-nntp-process-filter)
261 (with-current-buffer (elmo-network-session-buffer session)
262 (setq elmo-nntp-read-point (point-min))
263 ;; Skip garbage output from process before greeting.
264 (while (and (memq (process-status process) '(open run))
265 (goto-char (point-max))
267 (not (looking-at "^[2-5][0-9][0-9]")))
268 (accept-process-output process 1))
269 (setq elmo-nntp-read-point (point))
270 (setq response (elmo-nntp-read-response session t t))
271 (unless (car response)
272 (signal 'elmo-open-error (list (cdr response))))
273 (if elmo-nntp-send-mode-reader
274 (elmo-nntp-send-mode-reader session))
275 (when (eq (elmo-network-stream-type-symbol
276 (elmo-network-session-stream-type-internal session))
278 (elmo-nntp-send-command session "starttls")
279 (or (elmo-nntp-read-response session)
280 (error "Cannot open starttls session"))
281 (starttls-negotiate process)))))
283 (luna-define-method elmo-network-authenticate-session ((session
285 (with-current-buffer (elmo-network-session-buffer session)
286 (when (elmo-network-session-user-internal session)
287 (elmo-nntp-send-command session
288 (format "authinfo user %s"
289 (elmo-network-session-user-internal
291 (or (elmo-nntp-read-response session)
292 (signal 'elmo-authenticate-error '(authinfo)))
293 (elmo-nntp-send-command
295 (format "authinfo pass %s"
296 (elmo-get-passwd (elmo-network-session-password-key session))))
297 (or (elmo-nntp-read-response session)
298 (signal 'elmo-authenticate-error '(authinfo))))))
300 (luna-define-method elmo-network-setup-session ((session
302 (run-hooks 'elmo-nntp-opened-hook))
304 (defun elmo-nntp-process-filter (process output)
306 (set-buffer (process-buffer process))
307 (goto-char (point-max))
310 (defun elmo-nntp-send-mode-reader (session)
311 (elmo-nntp-send-command session "mode reader")
312 (if (null (elmo-nntp-read-response session t))
313 (message "Mode reader failed")))
315 (defun elmo-nntp-send-command (session command &optional noerase)
316 (with-current-buffer (elmo-network-session-buffer session)
319 (goto-char (point-min)))
320 (setq elmo-nntp-read-point (point))
321 (process-send-string (elmo-network-session-process-internal
323 (process-send-string (elmo-network-session-process-internal
326 (defun elmo-nntp-read-response (session &optional not-command error-msg)
327 (with-current-buffer (elmo-network-session-buffer session)
328 (let ((process (elmo-network-session-process-internal session))
329 (case-fold-search nil)
330 (response-string nil)
331 (response-continue t)
333 (while response-continue
334 (goto-char elmo-nntp-read-point)
335 (while (not (search-forward "\r\n" nil t))
336 (accept-process-output process)
337 (goto-char elmo-nntp-read-point))
338 (setq match-end (point))
339 (setq response-string
340 (buffer-substring elmo-nntp-read-point (- match-end 2)))
341 (goto-char elmo-nntp-read-point)
342 (if (looking-at "[23][0-9]+ .*$")
343 (progn (setq response-continue nil)
344 (setq elmo-nntp-read-point match-end)
347 (concat response "\n" response-string)
349 (if (looking-at "[^23][0-9]+ .*$")
350 (progn (setq response-continue nil)
351 (setq elmo-nntp-read-point match-end)
353 (setq elmo-nntp-read-point match-end)
355 (setq response-continue nil))
358 (concat response "\n" response-string)
360 (setq elmo-nntp-read-point match-end)))
362 (cons response response-string)
365 (defun elmo-nntp-read-raw-response (session)
366 (with-current-buffer (elmo-network-session-buffer session)
367 (goto-char elmo-nntp-read-point)
368 (while (not (search-forward "\r\n" nil t))
369 (accept-process-output (elmo-network-session-process-internal
371 (goto-char elmo-nntp-read-point))
372 (buffer-substring elmo-nntp-read-point (- (point) 2))))
374 (defun elmo-nntp-read-contents (session)
375 (with-current-buffer (elmo-network-session-buffer session)
376 (goto-char elmo-nntp-read-point)
377 (while (not (re-search-forward "^\\.\r\n" nil t))
378 (accept-process-output (elmo-network-session-process-internal
380 (goto-char elmo-nntp-read-point))
382 (buffer-substring elmo-nntp-read-point
385 (defun elmo-nntp-read-body (session outbuf)
386 (with-current-buffer (elmo-network-session-buffer session)
387 (goto-char elmo-nntp-read-point)
388 (while (not (re-search-forward "^\\.\r\n" nil t))
389 (accept-process-output (elmo-network-session-process-internal session))
390 (goto-char elmo-nntp-read-point))
391 (let ((start elmo-nntp-read-point)
393 (with-current-buffer outbuf
395 (insert-buffer-substring (elmo-network-session-buffer session)
399 (defun elmo-nntp-select-group (session group &optional force)
402 (not (string= (elmo-nntp-session-current-group-internal session)
406 (elmo-nntp-send-command session (format "group %s" group))
407 (setq response (elmo-nntp-read-response session)))
408 (elmo-nntp-session-set-current-group-internal session
409 (and response group))
412 (defun elmo-nntp-list-folders-get-cache (group server buf)
413 (when (and elmo-nntp-list-folders-use-cache
414 elmo-nntp-list-folders-cache
415 (string-match (concat "^"
418 (nth 1 elmo-nntp-list-folders-cache)
421 (string-match (concat "^"
424 (nth 2 elmo-nntp-list-folders-cache)
427 (let* ((cache-time (car elmo-nntp-list-folders-cache)))
428 (unless (elmo-time-expire cache-time
429 elmo-nntp-list-folders-use-cache)
433 (insert (nth 3 elmo-nntp-list-folders-cache))
434 (goto-char (point-min))
435 (or (string= group "")
437 (keep-lines (concat "^" (regexp-quote group) "\\."))))
441 (defsubst elmo-nntp-catchup-msgdb (msgdb max-number)
442 (let (msgdb-max number-alist)
443 (setq number-alist (elmo-msgdb-get-number-alist msgdb))
444 (setq msgdb-max (car (nth (max (- (length number-alist) 1) 0)
446 (if (or (not msgdb-max)
447 (and msgdb-max max-number
448 (< msgdb-max max-number)))
449 (elmo-msgdb-set-number-alist
451 (nconc number-alist (list (cons max-number nil)))))))
453 (luna-define-method elmo-folder-list-subfolders ((folder elmo-nntp-folder)
455 (elmo-nntp-folder-list-subfolders folder one-level))
457 (defun elmo-nntp-folder-list-subfolders (folder one-level)
458 (let ((session (elmo-nntp-get-session folder))
459 (case-fold-search nil)
460 response ret-val top-ng append-serv use-list-active start)
462 (set-buffer-multibyte nil)
463 (if (and (elmo-nntp-folder-group-internal folder)
464 (elmo-nntp-select-group
466 (elmo-nntp-folder-group-internal folder)))
467 ;; add top newsgroups
468 (setq ret-val (list (elmo-nntp-folder-group-internal folder))))
469 (unless (setq response (elmo-nntp-list-folders-get-cache
470 (elmo-nntp-folder-group-internal folder)
471 (elmo-net-folder-server-internal folder)
473 (when (setq use-list-active (elmo-nntp-list-active-p session))
474 (elmo-nntp-send-command
477 (if (and (elmo-nntp-folder-group-internal folder)
478 (not (string= (elmo-nntp-folder-group-internal
482 (elmo-nntp-folder-group-internal folder)
484 (if (elmo-nntp-read-response session t)
485 (if (null (setq response (elmo-nntp-read-contents session)))
486 (error "NNTP List folders failed")
487 (when elmo-nntp-list-folders-use-cache
488 (setq elmo-nntp-list-folders-cache
490 (elmo-nntp-folder-group-internal folder)
491 (elmo-net-folder-server-internal folder)
495 (elmo-nntp-set-list-active session nil)
496 (setq use-list-active nil)))
497 (when (null use-list-active)
498 (elmo-nntp-send-command session "list")
499 (if (null (and (elmo-nntp-read-response session t)
500 (setq response (elmo-nntp-read-contents session))))
501 (error "NNTP List folders failed"))
502 (when elmo-nntp-list-folders-use-cache
503 (setq elmo-nntp-list-folders-cache
504 (list (current-time) nil nil response)))
507 (while (string-match (concat "^"
510 (elmo-nntp-folder-group-internal
514 (insert (match-string 0 response) "\n")
515 (setq start (match-end 0)))))
516 (goto-char (point-min))
517 (let ((len (count-lines (point-min) (point-max)))
522 (format "^\\(%s[^. ]+\\)\\([. ]\\).*\n"
524 (elmo-nntp-folder-group-internal folder)
526 (elmo-nntp-folder-group-internal
528 (concat (elmo-nntp-folder-group-internal
531 (while (looking-at regexp)
532 (setq top-ng (elmo-match-buffer 1))
533 (if (string= (elmo-match-buffer 2) " ")
534 (if (not (or (member top-ng ret-val)
535 (assoc top-ng ret-val)))
536 (setq ret-val (nconc ret-val (list top-ng))))
537 (if (member top-ng ret-val)
538 (setq ret-val (delete top-ng ret-val)))
539 (if (not (assoc top-ng ret-val))
540 (setq ret-val (nconc ret-val (list (list top-ng))))))
541 (when (> len elmo-display-progress-threshold)
543 (if (or (zerop (% i 10)) (= i len))
544 (elmo-display-progress
545 'elmo-nntp-list-folders "Parsing active..."
548 (while (re-search-forward "\\([^ ]+\\) .*\n" nil t)
549 (setq ret-val (nconc ret-val
550 (list (elmo-match-buffer 1))))
551 (when (> len elmo-display-progress-threshold)
553 (if (or (zerop (% i 10)) (= i len))
554 (elmo-display-progress
555 'elmo-nntp-list-folders "Parsing active..."
556 (/ (* i 100) len))))))
557 (when (> len elmo-display-progress-threshold)
558 (elmo-display-progress
559 'elmo-nntp-list-folders "Parsing active..." 100))))
560 (unless (string= (elmo-net-folder-server-internal folder)
561 elmo-nntp-default-server)
562 (setq append-serv (concat "@" (elmo-net-folder-server-internal
564 (unless (eq (elmo-net-folder-port-internal folder) elmo-nntp-default-port)
565 (setq append-serv (concat append-serv
567 (elmo-net-folder-port-internal folder)))))
568 (unless (eq (elmo-network-stream-type-symbol
569 (elmo-net-folder-stream-type-internal folder))
570 elmo-nntp-default-stream-type)
573 (elmo-network-stream-type-spec-string
574 (elmo-net-folder-stream-type-internal folder)))))
575 (mapcar '(lambda (fld)
577 (list (concat "-" (elmo-nntp-decode-group-string (car fld))
578 (and (elmo-net-folder-user-internal folder)
581 (elmo-net-folder-user-internal folder)))
583 (concat append-serv))))
584 (concat "-" (elmo-nntp-decode-group-string fld)
585 (and (elmo-net-folder-user-internal folder)
586 (concat ":" (elmo-net-folder-user-internal
589 (concat append-serv)))))
592 (defun elmo-nntp-make-msglist (beg-str end-str)
594 (let ((beg-num (string-to-int beg-str))
595 (end-num (string-to-int end-str))
599 (while (<= i end-num)
600 (insert (format "%s " i))
603 (goto-char (point-min))
604 (read (current-buffer)))))
606 (luna-define-method elmo-folder-list-messages-plugged ((folder
609 (let ((session (elmo-nntp-get-session folder))
610 (group (elmo-nntp-folder-group-internal folder))
611 response numbers use-listgroup)
613 (when (setq use-listgroup (elmo-nntp-listgroup-p session))
614 (elmo-nntp-send-command session
615 (format "listgroup %s" group))
616 (if (not (elmo-nntp-read-response session t))
618 (elmo-nntp-set-listgroup session nil)
619 (setq use-listgroup nil))
620 (if (null (setq response (elmo-nntp-read-contents session)))
621 (error "Fetching listgroup failed"))
622 (setq numbers (elmo-string-to-list response))
623 (elmo-nntp-session-set-current-group-internal session
625 (unless use-listgroup
626 (elmo-nntp-send-command session (format "group %s" group))
627 (if (null (setq response (elmo-nntp-read-response session)))
628 (error "Select group failed"))
631 "211 \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\) [^.].+$"
633 (> (string-to-int (elmo-match-string 1 response)) 0))
634 (setq numbers (elmo-nntp-make-msglist
635 (elmo-match-string 2 response)
636 (elmo-match-string 3 response)))))
639 (luna-define-method elmo-folder-status ((folder elmo-nntp-folder))
640 (elmo-nntp-folder-status folder))
642 (defun elmo-nntp-folder-status (folder)
643 (let ((killed-list (elmo-msgdb-killed-list-load
644 (elmo-folder-msgdb-path folder)))
646 (if elmo-nntp-groups-async
649 (concat (elmo-nntp-folder-group-internal folder)
650 (elmo-nntp-folder-postfix
651 (elmo-net-folder-user-internal folder)
652 (elmo-net-folder-server-internal folder)
653 (elmo-net-folder-port-internal folder)
654 (elmo-net-folder-stream-type-internal folder)))
655 elmo-newsgroups-hashtb))
657 (setq end-num (nth 2 entry))
658 (when (and killed-list
659 (elmo-number-set-member end-num killed-list))
662 (cons end-num (car entry)))
663 (error "No such newsgroup \"%s\""
664 (elmo-nntp-folder-group-internal folder)))
665 (let ((session (elmo-nntp-get-session folder))
668 (error "Connection failed"))
670 (elmo-nntp-send-command session
673 (elmo-nntp-folder-group-internal folder)))
674 (setq response (elmo-nntp-read-response session))
677 "211 \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\) [^.].+$"
680 (setq end-num (string-to-int
681 (elmo-match-string 3 response)))
682 (setq e-num (string-to-int
683 (elmo-match-string 1 response)))
684 (when (and killed-list
685 (elmo-number-set-member end-num killed-list))
688 (cons end-num e-num))
690 (error "Selecting newsgroup \"%s\" failed"
691 (elmo-nntp-folder-group-internal folder))
694 (defconst elmo-nntp-overview-index
705 (defun elmo-nntp-create-msgdb-from-overview-string (str
708 (let (ov-list gmark message-id seen
709 ov-entity overview number-alist mark-alist num
710 extras extra ext field field-index)
711 (setq ov-list (elmo-nntp-parse-overview-string str))
713 (setq ov-entity (car ov-list))
715 ;;; (if (or (> (setq num (string-to-int (aref ov-entity 0)))
719 ;;; (setq num (int-to-string num))
720 (setq num (string-to-int (aref ov-entity 0)))
721 (when (or (null numlist)
723 (setq extras elmo-msgdb-extra-fields
726 (setq ext (downcase (car extras)))
727 (when (setq field-index (cdr (assoc ext elmo-nntp-overview-index)))
728 (when (> (length ov-entity) field-index)
729 (setq field (aref ov-entity field-index))
730 (when (eq field-index 8) ;; xref
731 (setq field (elmo-msgdb-remove-field-string field)))
732 (setq extra (cons (cons ext field) extra))))
733 (setq extras (cdr extras)))
735 (elmo-msgdb-append-element
737 (cons (aref ov-entity 4)
739 (elmo-msgdb-get-last-message-id
742 (elmo-mime-string (elmo-delete-char
748 (elmo-mime-string (or (aref ov-entity 1)
750 (aref ov-entity 3) ;date
754 (aref ov-entity 6)) ; size
755 extra ; extra-field-list
758 (elmo-msgdb-number-add number-alist num
760 (setq message-id (aref ov-entity 4))
761 (setq seen (member message-id seen-list))
762 (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
763 (if (elmo-file-cache-status
764 (elmo-file-cache-get message-id))
767 elmo-msgdb-unread-cached-mark)
769 (if elmo-nntp-use-cache
770 elmo-msgdb-read-uncached-mark)
771 elmo-msgdb-new-mark))))
773 (elmo-msgdb-mark-append mark-alist
775 (setq ov-list (cdr ov-list)))
776 (list overview number-alist mark-alist)))
778 (luna-define-method elmo-folder-msgdb-create ((folder elmo-nntp-folder)
780 (elmo-nntp-folder-msgdb-create folder numbers seen-list))
782 (defun elmo-nntp-folder-msgdb-create (folder numbers seen-list)
783 (let ((filter numbers)
784 (session (elmo-nntp-get-session folder))
785 beg-num end-num cur length
786 ret-val ov-str use-xover dir)
787 (elmo-nntp-select-group session (elmo-nntp-folder-group-internal
789 (when (setq use-xover (elmo-nntp-xover-p session))
790 (setq beg-num (car numbers)
792 end-num (nth (1- (length numbers)) numbers)
793 length (+ (- end-num beg-num) 1))
794 (message "Getting overview...")
795 (while (<= cur end-num)
796 (elmo-nntp-send-command
803 elmo-nntp-overview-fetch-chop-length))))
804 (with-current-buffer (elmo-network-session-buffer session)
809 (elmo-nntp-create-msgdb-from-overview-string
814 (if (null (elmo-nntp-read-response session t))
816 (setq cur end-num);; exit while loop
817 (elmo-nntp-set-xover session nil)
818 (setq use-xover nil))
819 (if (null (setq ov-str (elmo-nntp-read-contents session)))
820 (error "Fetching overview failed")))
821 (setq cur (+ elmo-nntp-overview-fetch-chop-length cur 1))
822 (when (> length elmo-display-progress-threshold)
823 (elmo-display-progress
824 'elmo-nntp-msgdb-create "Getting overview..."
825 (/ (* (+ (- (min cur end-num)
826 beg-num) 1) 100) length))))
827 (when (> length elmo-display-progress-threshold)
828 (elmo-display-progress
829 'elmo-nntp-msgdb-create "Getting overview..." 100)))
831 (setq ret-val (elmo-nntp-msgdb-create-by-header
832 session numbers seen-list))
833 (with-current-buffer (elmo-network-session-buffer session)
838 (elmo-nntp-create-msgdb-from-overview-string
842 (elmo-folder-set-killed-list-internal
845 (elmo-folder-killed-list-internal folder)
849 (elmo-msgdb-get-number-alist
851 ;; If there are canceled messages, overviews are not obtained
852 ;; to max-number(inn 2.3?).
853 (when (and (elmo-nntp-max-number-precedes-list-active-p)
854 (elmo-nntp-list-active-p session))
855 (elmo-nntp-send-command session
856 (format "list active %s"
857 (elmo-nntp-folder-group-internal
859 (if (null (elmo-nntp-read-response session))
861 (elmo-nntp-set-list-active session nil)
862 (error "NNTP list command failed")))
863 (elmo-nntp-catchup-msgdb
865 (nth 1 (read (concat "(" (elmo-nntp-read-contents
869 (luna-define-method elmo-folder-update-number ((folder elmo-nntp-folder))
870 (if (elmo-nntp-max-number-precedes-list-active-p)
871 (let ((session (elmo-nntp-get-session folder))
872 (number-alist (elmo-msgdb-get-number-alist
873 (elmo-folder-msgdb folder))))
874 (if (elmo-nntp-list-active-p session)
875 (let (msgdb-max max-number)
876 ;; If there are canceled messages, overviews are not obtained
877 ;; to max-number(inn 2.3?).
878 (elmo-nntp-select-group session
879 (elmo-nntp-folder-group-internal folder))
880 (elmo-nntp-send-command session
881 (format "list active %s"
882 (elmo-nntp-folder-group-internal
884 (if (null (elmo-nntp-read-response session))
885 (error "NNTP list command failed"))
887 (nth 1 (read (concat "(" (elmo-nntp-read-contents
890 (car (nth (max (- (length number-alist) 1) 0)
892 (if (or (and number-alist (not msgdb-max))
893 (and msgdb-max max-number
894 (< msgdb-max max-number)))
895 (elmo-msgdb-set-number-alist
896 (elmo-folder-msgdb folder)
898 (list (cons max-number nil))))))))))
900 (defun elmo-nntp-msgdb-create-by-header (session numbers seen-list)
902 (elmo-nntp-retrieve-headers session (current-buffer) numbers)
903 (elmo-nntp-msgdb-create-message
904 (length numbers) seen-list)))
906 (defun elmo-nntp-parse-xhdr-response (string)
910 (goto-char (point-min))
912 (if (looking-at "^\\([0-9]+\\) \\(.*\\)$")
913 (setq response (cons (cons (string-to-int (elmo-match-buffer 1))
914 (elmo-match-buffer 2))
917 (nreverse response)))
919 (defun elmo-nntp-parse-overview-string (string)
921 (let ((tmp-buffer (get-buffer-create " *ELMO Overview TMP*"))
922 ret-list ret-val beg)
923 (set-buffer tmp-buffer)
925 (elmo-set-buffer-multibyte nil)
927 (goto-char (point-min))
931 (setq ret-list (save-match-data
932 (apply 'vector (split-string
933 (buffer-substring beg (point))
938 (setq ret-val (nconc ret-val (list ret-list))))
939 ;;; (kill-buffer tmp-buffer)
942 (defun elmo-nntp-get-newsgroup-by-msgid (msgid server user port type)
943 "Get nntp header string."
945 (let ((session (elmo-nntp-get-session
951 :stream-type type))))
952 (elmo-nntp-send-command session
953 (format "head %s" msgid))
954 (if (elmo-nntp-read-response session)
955 (elmo-nntp-read-contents session))
956 (with-current-buffer (elmo-network-session-buffer session)
957 (std11-field-body "Newsgroups")))))
959 (luna-define-method elmo-message-fetch-with-cache-process :around
960 ((folder elmo-nntp-folder) number strategy &optional section unread)
961 (when (luna-call-next-method)
962 (elmo-nntp-setup-crosspost-buffer folder number)
964 (elmo-nntp-folder-update-crosspost-message-alist
965 folder (list number)))
968 (luna-define-method elmo-message-fetch-plugged ((folder elmo-nntp-folder)
970 &optional section outbuf
972 (elmo-nntp-message-fetch folder number strategy section outbuf unread))
974 (defun elmo-nntp-message-fetch (folder number strategy section outbuf unread)
975 (let ((session (elmo-nntp-get-session folder))
977 (with-current-buffer (elmo-network-session-buffer session)
978 (elmo-nntp-select-group session (elmo-nntp-folder-group-internal folder))
979 (elmo-nntp-send-command session (format "article %s" number))
980 (if (null (elmo-nntp-read-response session t))
982 (with-current-buffer outbuf (erase-buffer))
983 (message "Fetching message failed")
985 (prog1 (elmo-nntp-read-body session outbuf)
986 (with-current-buffer outbuf
987 (goto-char (point-min))
988 (while (re-search-forward "^\\." nil t)
991 (elmo-nntp-setup-crosspost-buffer folder number)
993 (elmo-nntp-folder-update-crosspost-message-alist
994 folder (list number)))))))))
996 (defun elmo-nntp-post (hostname content-buf)
997 (let ((session (elmo-nntp-get-session
1000 :user elmo-nntp-default-user
1002 :port elmo-nntp-default-port
1004 (elmo-get-network-stream-type
1005 elmo-nntp-default-stream-type))))
1006 response has-message-id)
1008 (set-buffer content-buf)
1009 (goto-char (point-min))
1010 (if (search-forward mail-header-separator nil t)
1011 (delete-region (match-beginning 0)(match-end 0)))
1012 (setq has-message-id (std11-field-body "message-id"))
1013 (elmo-nntp-send-command session "post")
1014 (if (string-match "^340" (setq response
1015 (elmo-nntp-read-raw-response session)))
1016 (if (string-match "recommended ID \\(<[^@]+@[^>]+>\\)" response)
1017 (unless has-message-id
1018 (goto-char (point-min))
1019 (insert (concat "Message-ID: "
1020 (elmo-match-string 1 response)
1022 (error "POST failed"))
1023 (run-hooks 'elmo-nntp-post-pre-hook)
1024 (elmo-nntp-send-buffer session content-buf)
1025 (elmo-nntp-send-command session ".")
1026 ;;; (elmo-nntp-read-response buffer process t)
1027 (if (not (string-match
1028 "^2" (setq response (elmo-nntp-read-raw-response
1030 (error (concat "NNTP error: " response))))))
1032 (defsubst elmo-nntp-send-data-line (session line)
1033 "Send LINE to SESSION."
1034 ;; Escape "." at start of a line
1035 (if (eq (string-to-char line) ?.)
1036 (process-send-string (elmo-network-session-process-internal
1038 (process-send-string (elmo-network-session-process-internal
1040 (process-send-string (elmo-network-session-process-internal
1043 (defun elmo-nntp-send-buffer (session databuf)
1044 "Send data content of DATABUF to SESSION."
1045 (let ((data-continue t)
1047 (with-current-buffer databuf
1048 (goto-char (point-min))
1049 (while data-continue
1053 (setq line (buffer-substring bol (point)))
1054 (unless (eq (forward-line 1) 0) (setq data-continue nil))
1055 (elmo-nntp-send-data-line session line)))))
1057 (luna-define-method elmo-folder-delete-messages ((folder elmo-nntp-folder)
1059 (elmo-nntp-folder-delete-messages folder numbers))
1061 (defun elmo-nntp-folder-delete-messages (folder numbers)
1062 (let ((killed-list (elmo-folder-killed-list-internal folder)))
1063 (dolist (number numbers)
1065 (elmo-msgdb-set-as-killed killed-list number)))
1066 (elmo-folder-set-killed-list-internal folder killed-list))
1069 (luna-define-method elmo-folder-exists-p-plugged ((folder elmo-nntp-folder))
1070 (let ((session (elmo-nntp-get-session folder)))
1071 (elmo-nntp-send-command
1074 (elmo-nntp-folder-group-internal folder)))
1075 (elmo-nntp-read-response session)))
1077 (defun elmo-nntp-retrieve-field (spec field from-msgs)
1078 "Retrieve FIELD values from FROM-MSGS.
1079 Returns a list of cons cells like (NUMBER . VALUE)"
1080 (let ((session (elmo-nntp-get-session spec)))
1081 (if (elmo-nntp-xhdr-p session)
1083 (elmo-nntp-select-group session (elmo-nntp-folder-group-internal spec))
1084 (elmo-nntp-send-command session
1085 (format "xhdr %s %s"
1093 (- (length from-msgs) 1) 0)
1096 (if (elmo-nntp-read-response session t)
1097 (elmo-nntp-parse-xhdr-response
1098 (elmo-nntp-read-contents session))
1099 (elmo-nntp-set-xhdr session nil)
1100 (error "NNTP XHDR command failed"))))))
1102 (defun elmo-nntp-search-primitive (spec condition &optional from-msgs)
1103 (let ((search-key (elmo-filter-key condition)))
1105 ((string= "last" search-key)
1106 (let ((numbers (or from-msgs (elmo-folder-list-messages spec))))
1107 (nthcdr (max (- (length numbers)
1108 (string-to-int (elmo-filter-value condition)))
1111 ((string= "first" search-key)
1112 (let* ((numbers (or from-msgs (elmo-folder-list-messages spec)))
1113 (rest (nthcdr (string-to-int (elmo-filter-value condition) )
1115 (mapcar '(lambda (x) (delete x numbers)) rest)
1117 ((or (string= "since" search-key)
1118 (string= "before" search-key))
1119 (let* ((specified-date (elmo-date-make-sortable-string
1120 (elmo-date-get-datevec (elmo-filter-value
1122 (since (string= "since" search-key))
1124 (if (eq (elmo-filter-type condition) 'unmatch)
1125 (setq since (not since)))
1131 (elmo-date-make-sortable-string
1134 (current-time-zone) nil)))
1136 (or (string= specified-date field-date)
1137 (string< specified-date field-date))
1141 (elmo-nntp-retrieve-field spec "date" from-msgs))))
1143 (elmo-list-filter from-msgs result)
1146 (let ((val (elmo-filter-value condition))
1147 (negative (eq (elmo-filter-type condition) 'unmatch))
1148 (case-fold-search t)
1154 (if (string-match val
1155 (eword-decode-string
1156 (decode-mime-charset-string
1157 (cdr pair) elmo-mime-charset)))
1158 (unless negative (car pair))
1159 (if negative (car pair))))
1160 (elmo-nntp-retrieve-field spec search-key
1163 (elmo-list-filter from-msgs result)
1166 (defun elmo-nntp-search-internal (folder condition from-msgs)
1169 ((vectorp condition)
1170 (setq result (elmo-nntp-search-primitive
1171 folder condition from-msgs)))
1172 ((eq (car condition) 'and)
1173 (setq result (elmo-nntp-search-internal folder
1176 result (elmo-list-filter result
1177 (elmo-nntp-search-internal
1178 folder (nth 2 condition)
1180 ((eq (car condition) 'or)
1181 (setq result (elmo-nntp-search-internal folder
1184 result (elmo-uniq-list
1186 (elmo-nntp-search-internal folder
1189 result (sort result '<))))))
1191 (luna-define-method elmo-folder-search :around ((folder elmo-nntp-folder)
1192 condition &optional from-msgs)
1193 (if (elmo-folder-plugged-p folder)
1194 (elmo-nntp-search-internal folder condition from-msgs)
1195 (luna-call-next-method)))
1197 (defun elmo-nntp-get-folders-info-prepare (folder session-keys)
1199 (let ((session (elmo-nntp-get-session folder))
1201 (with-current-buffer (elmo-network-session-buffer session)
1202 (unless (setq key (assoc session session-keys))
1204 (setq key (cons session
1206 (elmo-net-folder-server-internal folder)
1207 (elmo-net-folder-user-internal folder)
1208 (elmo-net-folder-port-internal folder)
1209 (elmo-net-folder-stream-type-internal
1211 (setq session-keys (nconc session-keys (list key))))
1212 (elmo-nntp-send-command session
1214 (elmo-nntp-folder-group-internal
1217 (if elmo-nntp-get-folders-securely
1218 (accept-process-output
1219 (elmo-network-session-process-internal session)
1221 (setq count (aref (cdr key) 0))
1222 (aset (cdr key) 0 (1+ count))))
1224 (when elmo-auto-change-plugged
1229 (defun elmo-nntp-get-folders-info (session-keys)
1230 (let ((sessions session-keys)
1231 (cur (get-buffer-create " *ELMO NNTP Temp*")))
1233 (let* ((session (caar sessions))
1234 (key (cdar sessions))
1235 (count (aref key 0))
1236 (server (aref key 1))
1240 (hashtb (or elmo-newsgroups-hashtb
1241 (setq elmo-newsgroups-hashtb
1242 (elmo-make-hash count)))))
1244 (elmo-nntp-groups-read-response session cur count)
1246 (goto-char (point-min))
1247 (let ((case-replace nil)
1248 (postfix (elmo-nntp-folder-postfix user server port type)))
1249 (if (not (string= postfix ""))
1251 (replace-regexp "^\\(211 [0-9]+ [0-9]+ [0-9]+ [^ \n]+\\).*$"
1253 (elmo-replace-in-string
1255 "\\\\" "\\\\\\\\\\\\\\\\"))))))
1256 (let (len min max group)
1259 (when (= (following-char) ?2)
1261 (setq len (read cur)
1264 (set (setq group (let ((obarray hashtb)) (read cur)))
1265 (list len min max)))
1266 (error (and group (symbolp group) (set group nil))))
1268 (setq sessions (cdr sessions))))
1271 ;; original is 'nntp-retrieve-groups [Gnus]
1272 (defun elmo-nntp-groups-read-response (session outbuf count)
1274 (last-point (point-min)))
1275 (with-current-buffer (elmo-network-session-buffer session)
1276 (accept-process-output
1277 (elmo-network-session-process-internal session) 1)
1279 ;; Wait for all replies.
1280 (message "Getting folders info...")
1282 (goto-char last-point)
1284 (while (re-search-forward "^[0-9]" nil t)
1287 (setq last-point (point))
1289 (accept-process-output (elmo-network-session-process-internal session)
1292 (when (> count elmo-display-progress-threshold)
1293 (if (or (zerop (% received 10)) (= received count))
1294 (elmo-display-progress
1295 'elmo-nntp-groups-read-response "Getting folders info..."
1296 (/ (* received 100) count)))))
1297 (when (> count elmo-display-progress-threshold)
1298 (elmo-display-progress
1299 'elmo-nntp-groups-read-response "Getting folders info..." 100))
1300 ;; Wait for the reply from the final command.
1301 (goto-char (point-max))
1302 (re-search-backward "^[0-9]" nil t)
1303 (when (looking-at "^[23]")
1305 (goto-char (point-max))
1306 (not (re-search-backward "\r?\n" (- (point) 3) t)))
1307 (accept-process-output
1308 (elmo-network-session-process-internal session) 1)
1310 ;; Now all replies are received. We remove CRs.
1311 (goto-char (point-min))
1312 (while (search-forward "\r" nil t)
1313 (replace-match "" t t))
1314 (copy-to-buffer outbuf (point-min) (point-max)))))
1316 ;; from nntp.el [Gnus]
1318 (defsubst elmo-nntp-next-result-arrived-p ()
1320 ((eq (following-char) ?2)
1321 (if (re-search-forward "\n\\.\r?\n" nil t)
1324 ((looking-at "[34]")
1325 (if (search-forward "\n" nil t)
1331 (defun elmo-nntp-retrieve-headers (session outbuf articles)
1332 "Retrieve the headers of ARTICLES."
1333 (with-current-buffer (elmo-network-session-buffer session)
1335 (let ((number (length articles))
1338 (last-point (point-min))
1340 ;; Send HEAD commands.
1341 (while (setq article (pop articles))
1342 (elmo-nntp-send-command session
1343 (format "head %s" article)
1345 (setq count (1+ count))
1346 ;; Every 200 requests we have to read the stream in
1347 ;; order to avoid deadlocks.
1348 (when (or (null articles) ;All requests have been sent.
1349 (zerop (% count elmo-nntp-header-fetch-chop-length)))
1350 (accept-process-output
1351 (elmo-network-session-process-internal session) 1)
1354 (goto-char last-point)
1356 (while (elmo-nntp-next-result-arrived-p)
1357 (setq last-point (point))
1358 (setq received (1+ received)))
1360 (when (> number elmo-display-progress-threshold)
1361 (if (or (zerop (% received 20)) (= received number))
1362 (elmo-display-progress
1363 'elmo-nntp-retrieve-headers "Getting headers..."
1364 (/ (* received 100) number))))
1365 (accept-process-output
1366 (elmo-network-session-process-internal session) 1)
1368 (when (> number elmo-display-progress-threshold)
1369 (elmo-display-progress
1370 'elmo-nntp-retrieve-headers "Getting headers..." 100))
1371 (message "Getting headers...done")
1372 ;; Remove all "\r"'s.
1373 (goto-char (point-min))
1374 (while (search-forward "\r\n" nil t)
1375 (replace-match "\n"))
1376 (copy-to-buffer outbuf (point-min) (point-max)))))
1380 (defun elmo-nntp-msgdb-create-message (len seen-list)
1382 (let (beg overview number-alist mark-alist
1383 entity i num gmark seen message-id)
1384 (elmo-set-buffer-multibyte nil)
1385 (goto-char (point-min))
1387 (message "Creating msgdb...")
1389 (setq beg (save-excursion (forward-line 1) (point)))
1391 (and (looking-at "^2[0-9]*[ ]+\\([0-9]+\\)")
1393 (elmo-match-buffer 1))))
1394 (elmo-nntp-next-result-arrived-p)
1399 (narrow-to-region beg (point))
1401 (elmo-msgdb-create-overview-from-buffer num))
1404 (elmo-msgdb-append-element
1407 (elmo-msgdb-number-add
1409 (elmo-msgdb-overview-entity-get-number entity)
1411 (setq message-id (car entity))
1412 (setq seen (member message-id seen-list))
1414 (or (elmo-msgdb-global-mark-get message-id)
1415 (if (elmo-file-cache-status
1416 (elmo-file-cache-get message-id))
1419 elmo-msgdb-unread-cached-mark)
1421 (if elmo-nntp-use-cache
1422 elmo-msgdb-read-uncached-mark)
1423 elmo-msgdb-new-mark))))
1425 (elmo-msgdb-mark-append
1429 (when (> len elmo-display-progress-threshold)
1431 (if (or (zerop (% i 20)) (= i len))
1432 (elmo-display-progress
1433 'elmo-nntp-msgdb-create-message "Creating msgdb..."
1434 (/ (* i 100) len)))))
1435 (when (> len elmo-display-progress-threshold)
1436 (elmo-display-progress
1437 'elmo-nntp-msgdb-create-message "Creating msgdb..." 100))
1438 (list overview number-alist mark-alist))))
1440 (luna-define-method elmo-message-use-cache-p ((folder elmo-nntp-folder) number)
1441 elmo-nntp-use-cache)
1443 (defun elmo-nntp-parse-newsgroups (string &optional subscribe-only)
1444 (let ((nglist (elmo-parse string "[ \t\f\r\n,]*\\([^ \t\f\r\n,]+\\)"))
1446 (if (not subscribe-only)
1449 (if (intern-soft ng elmo-newsgroups-hashtb)
1450 (setq ngs (cons ng ngs))))
1453 ;;; Crosspost processing.
1455 ;; 1. setup crosspost alist.
1456 ;; 1.1. When message is fetched and is crossposted message,
1457 ;; it is remembered in `temp-crosses' slot.
1458 ;; temp-crosses slot is a list of cons cell:
1459 ;; (NUMBER . (MESSAGE-ID (LIST-OF-NEWSGROUPS) 'ng))
1460 ;; 1.2. In elmo-folder-close, `temp-crosses' slot is cleared,
1461 ;; 1.3. In elmo-folder-mark-as-read, move crosspost entry
1462 ;; from `temp-crosses' slot to `elmo-crosspost-message-alist'.
1464 ;; 2. process crosspost alist.
1465 ;; 2.1. At elmo-folder-process-crosspost, setup `reads' slot from
1466 ;; `elmo-crosspost-message-alist'.
1467 ;; 2.2. remove crosspost entry for current newsgroup from
1468 ;; `elmo-crosspost-message-alist'.
1469 ;; 2.3. elmo-folder-list-unreads return unread message list according to
1471 ;; (There's a problem that if `elmo-folder-list-unreads'
1472 ;; never executed, crosspost information is thrown away.)
1473 ;; 2.4. In elmo-folder-close, `read' slot is cleared,
1475 (defun elmo-nntp-setup-crosspost-buffer (folder number)
1476 ;; 1.1. When message is fetched and is crossposted message,
1477 ;; it is remembered in `temp-crosses' slot.
1478 ;; temp-crosses slot is a list of cons cell:
1479 ;; (NUMBER . (MESSAGE-ID (LIST-OF-NEWSGROUPS) 'ng))
1480 (let (newsgroups crosspost-newsgroups message-id)
1482 (std11-narrow-to-header)
1483 (setq newsgroups (std11-fetch-field "newsgroups")
1484 message-id (std11-msg-id-string
1485 (car (std11-parse-msg-id-string
1486 (std11-fetch-field "message-id"))))))
1488 (when (setq crosspost-newsgroups
1490 (elmo-nntp-folder-group-internal folder)
1491 (elmo-nntp-parse-newsgroups newsgroups t)))
1492 (unless (assq number
1493 (elmo-nntp-folder-temp-crosses-internal folder))
1494 (elmo-nntp-folder-set-temp-crosses-internal
1496 (cons (cons number (list message-id crosspost-newsgroups 'ng))
1497 (elmo-nntp-folder-temp-crosses-internal folder))))))))
1499 (luna-define-method elmo-folder-close-internal ((folder elmo-nntp-folder))
1500 ;; 1.2. In elmo-folder-close, `temp-crosses' slot is cleared,
1501 (elmo-nntp-folder-set-temp-crosses-internal folder nil)
1502 (elmo-nntp-folder-set-reads-internal folder nil)
1505 (defun elmo-nntp-folder-update-crosspost-message-alist (folder numbers)
1506 ;; 1.3. In elmo-folder-mark-as-read, move crosspost entry
1507 ;; from `temp-crosses' slot to `elmo-crosspost-message-alist'.
1509 (dolist (number numbers)
1510 (when (setq elem (assq number
1511 (elmo-nntp-folder-temp-crosses-internal folder)))
1512 (unless (assoc (cdr (cdr elem)) elmo-crosspost-message-alist)
1513 (setq elmo-crosspost-message-alist
1514 (cons (cdr elem) elmo-crosspost-message-alist)))
1515 (elmo-nntp-folder-set-temp-crosses-internal
1517 (delq elem (elmo-nntp-folder-temp-crosses-internal folder)))))))
1519 (luna-define-method elmo-folder-mark-as-read :before ((folder
1522 &optional ignore-flags)
1523 (elmo-nntp-folder-update-crosspost-message-alist folder numbers))
1525 (luna-define-method elmo-folder-process-crosspost ((folder elmo-nntp-folder)
1528 (elmo-nntp-folder-process-crosspost folder number-alist))
1530 (defun elmo-nntp-folder-process-crosspost (folder number-alist)
1531 ;; 2.1. At elmo-folder-process-crosspost, setup `reads' slot from
1532 ;; `elmo-crosspost-message-alist'.
1533 ;; 2.2. remove crosspost entry for current newsgroup from
1534 ;; `elmo-crosspost-message-alist'.
1535 (let (cross-deletes reads entity ngs)
1536 (dolist (cross elmo-crosspost-message-alist)
1538 (when (setq entity (rassoc (nth 0 cross) number-alist))
1539 (setq reads (cons (car entity) reads)))
1540 (when (setq entity (elmo-msgdb-overview-get-entity
1542 (elmo-folder-msgdb folder)))
1543 (setq reads (cons (elmo-msgdb-overview-entity-get-number entity)
1546 (if (setq ngs (delete (elmo-nntp-folder-group-internal folder)
1548 (setcar (cdr cross) ngs)
1549 (setq cross-deletes (cons cross cross-deletes)))
1550 (setq elmo-crosspost-message-alist-modified t)))
1551 (dolist (dele cross-deletes)
1552 (setq elmo-crosspost-message-alist (delq
1554 elmo-crosspost-message-alist)))
1555 (elmo-nntp-folder-set-reads-internal folder reads)))
1557 (luna-define-method elmo-folder-list-unreads :around ((folder
1559 ;; 2.3. elmo-folder-list-unreads return unread message list according to
1561 (elmo-living-messages (luna-call-next-method)
1562 (elmo-nntp-folder-reads-internal folder)))
1565 (product-provide (provide 'elmo-nntp) (require 'elmo-version))
1567 ;;; elmo-nntp.el ends here