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
712 (let (ov-list gmark message-id seen
713 ov-entity overview number-alist mark-alist num
714 extras extra ext field field-index)
715 (setq ov-list (elmo-nntp-parse-overview-string str))
717 (setq ov-entity (car ov-list))
719 ;;; (if (or (> (setq num (string-to-int (aref ov-entity 0)))
723 ;;; (setq num (int-to-string num))
724 (setq num (string-to-int (aref ov-entity 0)))
725 (when (or (null numlist)
727 (setq extras elmo-msgdb-extra-fields
730 (setq ext (downcase (car extras)))
731 (when (setq field-index (cdr (assoc ext elmo-nntp-overview-index)))
732 (when (> (length ov-entity) field-index)
733 (setq field (aref ov-entity field-index))
734 (when (eq field-index 8) ;; xref
735 (setq field (elmo-msgdb-remove-field-string field)))
736 (setq extra (cons (cons ext field) extra))))
737 (setq extras (cdr extras)))
739 (elmo-msgdb-append-element
741 (cons (aref ov-entity 4)
743 (elmo-msgdb-get-last-message-id
746 (elmo-mime-string (elmo-delete-char
752 (elmo-mime-string (or (aref ov-entity 1)
754 (aref ov-entity 3) ;date
758 (aref ov-entity 6)) ; size
759 extra ; extra-field-list
762 (elmo-msgdb-number-add number-alist num
764 (setq message-id (aref ov-entity 4))
765 (setq seen (member message-id seen-list))
766 (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
767 (if (elmo-file-cache-status
768 (elmo-file-cache-get message-id))
773 (if elmo-nntp-use-cache
777 (elmo-msgdb-mark-append mark-alist
779 (setq ov-list (cdr ov-list)))
780 (list overview number-alist mark-alist)))
782 (luna-define-method elmo-folder-msgdb-create ((folder elmo-nntp-folder)
783 numbers new-mark already-mark
784 seen-mark important-mark
786 (elmo-nntp-folder-msgdb-create folder numbers new-mark already-mark
787 seen-mark important-mark
790 (defun elmo-nntp-folder-msgdb-create (folder numbers new-mark already-mark
791 seen-mark important-mark
793 (let ((filter numbers)
794 (session (elmo-nntp-get-session folder))
795 beg-num end-num cur length
796 ret-val ov-str use-xover dir)
797 (elmo-nntp-select-group session (elmo-nntp-folder-group-internal
799 (when (setq use-xover (elmo-nntp-xover-p session))
800 (setq beg-num (car numbers)
802 end-num (nth (1- (length numbers)) numbers)
803 length (+ (- end-num beg-num) 1))
804 (message "Getting overview...")
805 (while (<= cur end-num)
806 (elmo-nntp-send-command
813 elmo-nntp-overview-fetch-chop-length))))
814 (with-current-buffer (elmo-network-session-buffer session)
819 (elmo-nntp-create-msgdb-from-overview-string
828 (if (null (elmo-nntp-read-response session t))
830 (setq cur end-num);; exit while loop
831 (elmo-nntp-set-xover session nil)
832 (setq use-xover nil))
833 (if (null (setq ov-str (elmo-nntp-read-contents session)))
834 (error "Fetching overview failed")))
835 (setq cur (+ elmo-nntp-overview-fetch-chop-length cur 1))
836 (when (> length elmo-display-progress-threshold)
837 (elmo-display-progress
838 'elmo-nntp-msgdb-create "Getting overview..."
839 (/ (* (+ (- (min cur end-num)
840 beg-num) 1) 100) length))))
841 (when (> length elmo-display-progress-threshold)
842 (elmo-display-progress
843 'elmo-nntp-msgdb-create "Getting overview..." 100)))
845 (setq ret-val (elmo-nntp-msgdb-create-by-header
847 new-mark already-mark seen-mark seen-list))
848 (with-current-buffer (elmo-network-session-buffer session)
853 (elmo-nntp-create-msgdb-from-overview-string
861 (elmo-folder-set-killed-list-internal
864 (elmo-folder-killed-list-internal folder)
868 (elmo-msgdb-get-number-alist
870 ;; If there are canceled messages, overviews are not obtained
871 ;; to max-number(inn 2.3?).
872 (when (and (elmo-nntp-max-number-precedes-list-active-p)
873 (elmo-nntp-list-active-p session))
874 (elmo-nntp-send-command session
875 (format "list active %s"
876 (elmo-nntp-folder-group-internal
878 (if (null (elmo-nntp-read-response session))
880 (elmo-nntp-set-list-active session nil)
881 (error "NNTP list command failed")))
882 (elmo-nntp-catchup-msgdb
884 (nth 1 (read (concat "(" (elmo-nntp-read-contents
888 (luna-define-method elmo-folder-update-number ((folder elmo-nntp-folder))
889 (if (elmo-nntp-max-number-precedes-list-active-p)
890 (let ((session (elmo-nntp-get-session folder))
891 (number-alist (elmo-msgdb-get-number-alist
892 (elmo-folder-msgdb folder))))
893 (if (elmo-nntp-list-active-p session)
894 (let (msgdb-max max-number)
895 ;; If there are canceled messages, overviews are not obtained
896 ;; to max-number(inn 2.3?).
897 (elmo-nntp-select-group session
898 (elmo-nntp-folder-group-internal folder))
899 (elmo-nntp-send-command session
900 (format "list active %s"
901 (elmo-nntp-folder-group-internal
903 (if (null (elmo-nntp-read-response session))
904 (error "NNTP list command failed"))
906 (nth 1 (read (concat "(" (elmo-nntp-read-contents
909 (car (nth (max (- (length number-alist) 1) 0)
911 (if (or (and number-alist (not msgdb-max))
912 (and msgdb-max max-number
913 (< msgdb-max max-number)))
914 (elmo-msgdb-set-number-alist
915 (elmo-folder-msgdb folder)
917 (list (cons max-number nil))))))))))
919 (defun elmo-nntp-msgdb-create-by-header (session numbers
920 new-mark already-mark
923 (elmo-nntp-retrieve-headers session (current-buffer) numbers)
924 (elmo-nntp-msgdb-create-message
925 (length numbers) new-mark already-mark seen-mark seen-list)))
927 (defun elmo-nntp-parse-xhdr-response (string)
931 (goto-char (point-min))
933 (if (looking-at "^\\([0-9]+\\) \\(.*\\)$")
934 (setq response (cons (cons (string-to-int (elmo-match-buffer 1))
935 (elmo-match-buffer 2))
938 (nreverse response)))
940 (defun elmo-nntp-parse-overview-string (string)
942 (let ((tmp-buffer (get-buffer-create " *ELMO Overview TMP*"))
943 ret-list ret-val beg)
944 (set-buffer tmp-buffer)
946 (elmo-set-buffer-multibyte nil)
948 (goto-char (point-min))
952 (setq ret-list (save-match-data
953 (apply 'vector (split-string
954 (buffer-substring beg (point))
959 (setq ret-val (nconc ret-val (list ret-list))))
960 ;;; (kill-buffer tmp-buffer)
963 (defun elmo-nntp-get-newsgroup-by-msgid (msgid server user port type)
964 "Get nntp header string."
966 (let ((session (elmo-nntp-get-session
972 :stream-type type))))
973 (elmo-nntp-send-command session
974 (format "head %s" msgid))
975 (if (elmo-nntp-read-response session)
976 (elmo-nntp-read-contents session))
977 (with-current-buffer (elmo-network-session-buffer session)
978 (std11-field-body "Newsgroups")))))
980 (luna-define-method elmo-message-fetch-with-cache-process :around
981 ((folder elmo-nntp-folder) number strategy &optional section unread)
982 (when (luna-call-next-method)
983 (elmo-nntp-setup-crosspost-buffer folder number)
985 (elmo-nntp-folder-update-crosspost-message-alist
986 folder (list number)))
989 (luna-define-method elmo-message-fetch-plugged ((folder elmo-nntp-folder)
991 &optional section outbuf
993 (elmo-nntp-message-fetch folder number strategy section outbuf unread))
995 (defun elmo-nntp-message-fetch (folder number strategy section outbuf unread)
996 (let ((session (elmo-nntp-get-session folder))
998 (with-current-buffer (elmo-network-session-buffer session)
999 (elmo-nntp-select-group session (elmo-nntp-folder-group-internal folder))
1000 (elmo-nntp-send-command session (format "article %s" number))
1001 (if (null (elmo-nntp-read-response session t))
1003 (with-current-buffer outbuf (erase-buffer))
1004 (message "Fetching message failed")
1006 (prog1 (elmo-nntp-read-body session outbuf)
1007 (with-current-buffer outbuf
1008 (goto-char (point-min))
1009 (while (re-search-forward "^\\." nil t)
1012 (elmo-nntp-setup-crosspost-buffer folder number)
1014 (elmo-nntp-folder-update-crosspost-message-alist
1015 folder (list number)))))))))
1017 (defun elmo-nntp-post (hostname content-buf)
1018 (let ((session (elmo-nntp-get-session
1021 :user elmo-nntp-default-user
1023 :port elmo-nntp-default-port
1025 (elmo-get-network-stream-type
1026 elmo-nntp-default-stream-type))))
1027 response has-message-id)
1029 (set-buffer content-buf)
1030 (goto-char (point-min))
1031 (if (search-forward mail-header-separator nil t)
1032 (delete-region (match-beginning 0)(match-end 0)))
1033 (setq has-message-id (std11-field-body "message-id"))
1034 (elmo-nntp-send-command session "post")
1035 (if (string-match "^340" (setq response
1036 (elmo-nntp-read-raw-response session)))
1037 (if (string-match "recommended ID \\(<[^@]+@[^>]+>\\)" response)
1038 (unless has-message-id
1039 (goto-char (point-min))
1040 (insert (concat "Message-ID: "
1041 (elmo-match-string 1 response)
1043 (error "POST failed"))
1044 (run-hooks 'elmo-nntp-post-pre-hook)
1045 (elmo-nntp-send-buffer session content-buf)
1046 (elmo-nntp-send-command session ".")
1047 ;;; (elmo-nntp-read-response buffer process t)
1048 (if (not (string-match
1049 "^2" (setq response (elmo-nntp-read-raw-response
1051 (error (concat "NNTP error: " response))))))
1053 (defsubst elmo-nntp-send-data-line (session line)
1054 "Send LINE to SESSION."
1055 ;; Escape "." at start of a line
1056 (if (eq (string-to-char line) ?.)
1057 (process-send-string (elmo-network-session-process-internal
1059 (process-send-string (elmo-network-session-process-internal
1061 (process-send-string (elmo-network-session-process-internal
1064 (defun elmo-nntp-send-buffer (session databuf)
1065 "Send data content of DATABUF to SESSION."
1066 (let ((data-continue t)
1068 (with-current-buffer databuf
1069 (goto-char (point-min))
1070 (while data-continue
1074 (setq line (buffer-substring bol (point)))
1075 (unless (eq (forward-line 1) 0) (setq data-continue nil))
1076 (elmo-nntp-send-data-line session line)))))
1078 (luna-define-method elmo-folder-delete-messages ((folder elmo-nntp-folder)
1080 (elmo-nntp-folder-delete-messages folder numbers))
1082 (defun elmo-nntp-folder-delete-messages (folder numbers)
1083 (let ((killed-list (elmo-folder-killed-list-internal folder)))
1084 (dolist (number numbers)
1086 (elmo-msgdb-set-as-killed killed-list number)))
1087 (elmo-folder-set-killed-list-internal folder killed-list))
1090 (luna-define-method elmo-folder-exists-p-plugged ((folder elmo-nntp-folder))
1091 (let ((session (elmo-nntp-get-session folder)))
1092 (elmo-nntp-send-command
1095 (elmo-nntp-folder-group-internal folder)))
1096 (elmo-nntp-read-response session)))
1098 (defun elmo-nntp-retrieve-field (spec field from-msgs)
1099 "Retrieve FIELD values from FROM-MSGS.
1100 Returns a list of cons cells like (NUMBER . VALUE)"
1101 (let ((session (elmo-nntp-get-session spec)))
1102 (if (elmo-nntp-xhdr-p session)
1104 (elmo-nntp-select-group session (elmo-nntp-folder-group-internal spec))
1105 (elmo-nntp-send-command session
1106 (format "xhdr %s %s"
1114 (- (length from-msgs) 1) 0)
1117 (if (elmo-nntp-read-response session t)
1118 (elmo-nntp-parse-xhdr-response
1119 (elmo-nntp-read-contents session))
1120 (elmo-nntp-set-xhdr session nil)
1121 (error "NNTP XHDR command failed"))))))
1123 (defun elmo-nntp-search-primitive (spec condition &optional from-msgs)
1124 (let ((search-key (elmo-filter-key condition)))
1126 ((string= "last" search-key)
1127 (let ((numbers (or from-msgs (elmo-folder-list-messages spec))))
1128 (nthcdr (max (- (length numbers)
1129 (string-to-int (elmo-filter-value condition)))
1132 ((string= "first" search-key)
1133 (let* ((numbers (or from-msgs (elmo-folder-list-messages spec)))
1134 (rest (nthcdr (string-to-int (elmo-filter-value condition) )
1136 (mapcar '(lambda (x) (delete x numbers)) rest)
1138 ((or (string= "since" search-key)
1139 (string= "before" search-key))
1140 (let* ((specified-date (elmo-date-make-sortable-string
1141 (elmo-date-get-datevec (elmo-filter-value
1143 (since (string= "since" search-key))
1145 (if (eq (elmo-filter-type condition) 'unmatch)
1146 (setq since (not since)))
1152 (elmo-date-make-sortable-string
1155 (current-time-zone) nil)))
1157 (or (string= specified-date field-date)
1158 (string< specified-date field-date))
1162 (elmo-nntp-retrieve-field spec "date" from-msgs))))
1164 (elmo-list-filter from-msgs result)
1167 (let ((val (elmo-filter-value condition))
1168 (negative (eq (elmo-filter-type condition) 'unmatch))
1169 (case-fold-search t)
1175 (if (string-match val
1176 (eword-decode-string
1177 (decode-mime-charset-string
1178 (cdr pair) elmo-mime-charset)))
1179 (unless negative (car pair))
1180 (if negative (car pair))))
1181 (elmo-nntp-retrieve-field spec search-key
1184 (elmo-list-filter from-msgs result)
1187 (defun elmo-nntp-search-internal (folder condition from-msgs)
1190 ((vectorp condition)
1191 (setq result (elmo-nntp-search-primitive
1192 folder condition from-msgs)))
1193 ((eq (car condition) 'and)
1194 (setq result (elmo-nntp-search-internal folder
1197 result (elmo-list-filter result
1198 (elmo-nntp-search-internal
1199 folder (nth 2 condition)
1201 ((eq (car condition) 'or)
1202 (setq result (elmo-nntp-search-internal folder
1205 result (elmo-uniq-list
1207 (elmo-nntp-search-internal folder
1210 result (sort result '<))))))
1212 (luna-define-method elmo-folder-search :around ((folder elmo-nntp-folder)
1213 condition &optional from-msgs)
1214 (if (elmo-folder-plugged-p folder)
1215 (elmo-nntp-search-internal folder condition from-msgs)
1216 (luna-call-next-method)))
1218 (defun elmo-nntp-get-folders-info-prepare (folder session-keys)
1220 (let ((session (elmo-nntp-get-session folder))
1222 (with-current-buffer (elmo-network-session-buffer session)
1223 (unless (setq key (assoc session session-keys))
1225 (setq key (cons session
1227 (elmo-net-folder-server-internal folder)
1228 (elmo-net-folder-user-internal folder)
1229 (elmo-net-folder-port-internal folder)
1230 (elmo-net-folder-stream-type-internal
1232 (setq session-keys (nconc session-keys (list key))))
1233 (elmo-nntp-send-command session
1235 (elmo-nntp-folder-group-internal
1238 (if elmo-nntp-get-folders-securely
1239 (accept-process-output
1240 (elmo-network-session-process-internal session)
1242 (setq count (aref (cdr key) 0))
1243 (aset (cdr key) 0 (1+ count))))
1245 (when elmo-auto-change-plugged
1250 (defun elmo-nntp-get-folders-info (session-keys)
1251 (let ((sessions session-keys)
1252 (cur (get-buffer-create " *ELMO NNTP Temp*")))
1254 (let* ((session (caar sessions))
1255 (key (cdar sessions))
1256 (count (aref key 0))
1257 (server (aref key 1))
1261 (hashtb (or elmo-newsgroups-hashtb
1262 (setq elmo-newsgroups-hashtb
1263 (elmo-make-hash count)))))
1265 (elmo-nntp-groups-read-response session cur count)
1267 (goto-char (point-min))
1268 (let ((case-replace nil)
1269 (postfix (elmo-nntp-folder-postfix user server port type)))
1270 (if (not (string= postfix ""))
1272 (replace-regexp "^\\(211 [0-9]+ [0-9]+ [0-9]+ [^ \n]+\\).*$"
1274 (elmo-replace-in-string
1276 "\\\\" "\\\\\\\\\\\\\\\\"))))))
1277 (let (len min max group)
1280 (when (= (following-char) ?2)
1282 (setq len (read cur)
1285 (set (setq group (let ((obarray hashtb)) (read cur)))
1286 (list len min max)))
1287 (error (and group (symbolp group) (set group nil))))
1289 (setq sessions (cdr sessions))))
1292 ;; original is 'nntp-retrieve-groups [Gnus]
1293 (defun elmo-nntp-groups-read-response (session outbuf count)
1295 (last-point (point-min)))
1296 (with-current-buffer (elmo-network-session-buffer session)
1297 (accept-process-output
1298 (elmo-network-session-process-internal session) 1)
1300 ;; Wait for all replies.
1301 (message "Getting folders info...")
1303 (goto-char last-point)
1305 (while (re-search-forward "^[0-9]" nil t)
1308 (setq last-point (point))
1310 (accept-process-output (elmo-network-session-process-internal session)
1313 (when (> count elmo-display-progress-threshold)
1314 (if (or (zerop (% received 10)) (= received count))
1315 (elmo-display-progress
1316 'elmo-nntp-groups-read-response "Getting folders info..."
1317 (/ (* received 100) count)))))
1318 (when (> count elmo-display-progress-threshold)
1319 (elmo-display-progress
1320 'elmo-nntp-groups-read-response "Getting folders info..." 100))
1321 ;; Wait for the reply from the final command.
1322 (goto-char (point-max))
1323 (re-search-backward "^[0-9]" nil t)
1324 (when (looking-at "^[23]")
1326 (goto-char (point-max))
1327 (not (re-search-backward "\r?\n" (- (point) 3) t)))
1328 (accept-process-output
1329 (elmo-network-session-process-internal session) 1)
1331 ;; Now all replies are received. We remove CRs.
1332 (goto-char (point-min))
1333 (while (search-forward "\r" nil t)
1334 (replace-match "" t t))
1335 (copy-to-buffer outbuf (point-min) (point-max)))))
1337 ;; from nntp.el [Gnus]
1339 (defsubst elmo-nntp-next-result-arrived-p ()
1341 ((eq (following-char) ?2)
1342 (if (re-search-forward "\n\\.\r?\n" nil t)
1345 ((looking-at "[34]")
1346 (if (search-forward "\n" nil t)
1352 (defun elmo-nntp-retrieve-headers (session outbuf articles)
1353 "Retrieve the headers of ARTICLES."
1354 (with-current-buffer (elmo-network-session-buffer session)
1356 (let ((number (length articles))
1359 (last-point (point-min))
1361 ;; Send HEAD commands.
1362 (while (setq article (pop articles))
1363 (elmo-nntp-send-command session
1364 (format "head %s" article)
1366 (setq count (1+ count))
1367 ;; Every 200 requests we have to read the stream in
1368 ;; order to avoid deadlocks.
1369 (when (or (null articles) ;All requests have been sent.
1370 (zerop (% count elmo-nntp-header-fetch-chop-length)))
1371 (accept-process-output
1372 (elmo-network-session-process-internal session) 1)
1375 (goto-char last-point)
1377 (while (elmo-nntp-next-result-arrived-p)
1378 (setq last-point (point))
1379 (setq received (1+ received)))
1381 (when (> number elmo-display-progress-threshold)
1382 (if (or (zerop (% received 20)) (= received number))
1383 (elmo-display-progress
1384 'elmo-nntp-retrieve-headers "Getting headers..."
1385 (/ (* received 100) number))))
1386 (accept-process-output
1387 (elmo-network-session-process-internal session) 1)
1389 (when (> number elmo-display-progress-threshold)
1390 (elmo-display-progress
1391 'elmo-nntp-retrieve-headers "Getting headers..." 100))
1392 (message "Getting headers...done")
1393 ;; Remove all "\r"'s.
1394 (goto-char (point-min))
1395 (while (search-forward "\r\n" nil t)
1396 (replace-match "\n"))
1397 (copy-to-buffer outbuf (point-min) (point-max)))))
1401 (defun elmo-nntp-msgdb-create-message (len new-mark
1402 already-mark seen-mark seen-list)
1404 (let (beg overview number-alist mark-alist
1405 entity i num gmark seen message-id)
1406 (elmo-set-buffer-multibyte nil)
1407 (goto-char (point-min))
1409 (message "Creating msgdb...")
1411 (setq beg (save-excursion (forward-line 1) (point)))
1413 (and (looking-at "^2[0-9]*[ ]+\\([0-9]+\\)")
1415 (elmo-match-buffer 1))))
1416 (elmo-nntp-next-result-arrived-p)
1421 (narrow-to-region beg (point))
1423 (elmo-msgdb-create-overview-from-buffer num))
1426 (elmo-msgdb-append-element
1429 (elmo-msgdb-number-add
1431 (elmo-msgdb-overview-entity-get-number entity)
1433 (setq message-id (car entity))
1434 (setq seen (member message-id seen-list))
1436 (or (elmo-msgdb-global-mark-get message-id)
1437 (if (elmo-file-cache-status
1438 (elmo-file-cache-get message-id))
1443 (if elmo-nntp-use-cache
1447 (elmo-msgdb-mark-append
1451 (when (> len elmo-display-progress-threshold)
1453 (if (or (zerop (% i 20)) (= i len))
1454 (elmo-display-progress
1455 'elmo-nntp-msgdb-create-message "Creating msgdb..."
1456 (/ (* i 100) len)))))
1457 (when (> len elmo-display-progress-threshold)
1458 (elmo-display-progress
1459 'elmo-nntp-msgdb-create-message "Creating msgdb..." 100))
1460 (list overview number-alist mark-alist))))
1462 (luna-define-method elmo-message-use-cache-p ((folder elmo-nntp-folder) number)
1463 elmo-nntp-use-cache)
1465 (defun elmo-nntp-parse-newsgroups (string &optional subscribe-only)
1466 (let ((nglist (elmo-parse string "[ \t\f\r\n,]*\\([^ \t\f\r\n,]+\\)"))
1468 (if (not subscribe-only)
1471 (if (intern-soft ng elmo-newsgroups-hashtb)
1472 (setq ngs (cons ng ngs))))
1475 ;;; Crosspost processing.
1477 ;; 1. setup crosspost alist.
1478 ;; 1.1. When message is fetched and is crossposted message,
1479 ;; it is remembered in `temp-crosses' slot.
1480 ;; temp-crosses slot is a list of cons cell:
1481 ;; (NUMBER . (MESSAGE-ID (LIST-OF-NEWSGROUPS) 'ng))
1482 ;; 1.2. In elmo-folder-close, `temp-crosses' slot is cleared,
1483 ;; 1.3. In elmo-folder-mark-as-read, move crosspost entry
1484 ;; from `temp-crosses' slot to `elmo-crosspost-message-alist'.
1486 ;; 2. process crosspost alist.
1487 ;; 2.1. At elmo-folder-process-crosspost, setup `reads' slot from
1488 ;; `elmo-crosspost-message-alist'.
1489 ;; 2.2. remove crosspost entry for current newsgroup from
1490 ;; `elmo-crosspost-message-alist'.
1491 ;; 2.3. elmo-folder-list-unreads return unread message list according to
1493 ;; (There's a problem that if `elmo-folder-list-unreads'
1494 ;; never executed, crosspost information is thrown away.)
1495 ;; 2.4. In elmo-folder-close, `read' slot is cleared,
1497 (defun elmo-nntp-setup-crosspost-buffer (folder number)
1498 ;; 1.1. When message is fetched and is crossposted message,
1499 ;; it is remembered in `temp-crosses' slot.
1500 ;; temp-crosses slot is a list of cons cell:
1501 ;; (NUMBER . (MESSAGE-ID (LIST-OF-NEWSGROUPS) 'ng))
1502 (let (newsgroups crosspost-newsgroups message-id)
1504 (std11-narrow-to-header)
1505 (setq newsgroups (std11-fetch-field "newsgroups")
1506 message-id (std11-msg-id-string
1507 (car (std11-parse-msg-id-string
1508 (std11-fetch-field "message-id"))))))
1510 (when (setq crosspost-newsgroups
1512 (elmo-nntp-folder-group-internal folder)
1513 (elmo-nntp-parse-newsgroups newsgroups t)))
1514 (unless (assq number
1515 (elmo-nntp-folder-temp-crosses-internal folder))
1516 (elmo-nntp-folder-set-temp-crosses-internal
1518 (cons (cons number (list message-id crosspost-newsgroups 'ng))
1519 (elmo-nntp-folder-temp-crosses-internal folder))))))))
1521 (luna-define-method elmo-folder-close-internal ((folder elmo-nntp-folder))
1522 ;; 1.2. In elmo-folder-close, `temp-crosses' slot is cleared,
1523 (elmo-nntp-folder-set-temp-crosses-internal folder nil)
1524 (elmo-nntp-folder-set-reads-internal folder nil)
1527 (defun elmo-nntp-folder-update-crosspost-message-alist (folder numbers)
1528 ;; 1.3. In elmo-folder-mark-as-read, move crosspost entry
1529 ;; from `temp-crosses' slot to `elmo-crosspost-message-alist'.
1531 (dolist (number numbers)
1532 (when (setq elem (assq number
1533 (elmo-nntp-folder-temp-crosses-internal folder)))
1534 (unless (assoc (cdr (cdr elem)) elmo-crosspost-message-alist)
1535 (setq elmo-crosspost-message-alist
1536 (cons (cdr elem) elmo-crosspost-message-alist)))
1537 (elmo-nntp-folder-set-temp-crosses-internal
1539 (delq elem (elmo-nntp-folder-temp-crosses-internal folder)))))))
1541 (luna-define-method elmo-folder-mark-as-read ((folder elmo-nntp-folder)
1543 (elmo-nntp-folder-update-crosspost-message-alist folder numbers)
1546 (luna-define-method elmo-folder-process-crosspost ((folder elmo-nntp-folder)
1549 (elmo-nntp-folder-process-crosspost folder number-alist))
1551 (defun elmo-nntp-folder-process-crosspost (folder number-alist)
1552 ;; 2.1. At elmo-folder-process-crosspost, setup `reads' slot from
1553 ;; `elmo-crosspost-message-alist'.
1554 ;; 2.2. remove crosspost entry for current newsgroup from
1555 ;; `elmo-crosspost-message-alist'.
1556 (let (cross-deletes reads entity ngs)
1557 (dolist (cross elmo-crosspost-message-alist)
1559 (when (setq entity (rassoc (nth 0 cross) number-alist))
1560 (setq reads (cons (car entity) reads)))
1561 (when (setq entity (elmo-msgdb-overview-get-entity
1563 (elmo-folder-msgdb folder)))
1564 (setq reads (cons (elmo-msgdb-overview-entity-get-number entity)
1567 (if (setq ngs (delete (elmo-nntp-folder-group-internal folder)
1569 (setcar (cdr cross) ngs)
1570 (setq cross-deletes (cons cross cross-deletes)))
1571 (setq elmo-crosspost-message-alist-modified t)))
1572 (dolist (dele cross-deletes)
1573 (setq elmo-crosspost-message-alist (delq
1575 elmo-crosspost-message-alist)))
1576 (elmo-nntp-folder-set-reads-internal folder reads)))
1578 (luna-define-method elmo-folder-list-unreads-internal
1579 ((folder elmo-nntp-folder) unread-marks mark-alist)
1580 ;; 2.3. elmo-folder-list-unreads return unread message list according to
1582 (let ((mark-alist (or mark-alist (elmo-msgdb-get-mark-alist
1583 (elmo-folder-msgdb folder)))))
1584 (elmo-living-messages (delq nil
1587 (if (member (nth 1 x) unread-marks)
1590 (elmo-nntp-folder-reads-internal folder))))
1593 (product-provide (provide 'elmo-nntp) (require 'elmo-version))
1595 ;;; elmo-nntp.el ends here