1 ;;; sb-lump.el --- shimbun backend class to check all groups at once
3 ;; Author: TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>
4 ;; Akihiro Arisawa <ari@atesoft.advantest.co.jp>
5 ;; Yuuichi Teranishi <teranisi@gohome.org>
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
28 ;; Original code was nnshimbun.el written by
29 ;; TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>.
34 (defvar shimbun-lump-check-interval 300)
37 (luna-define-class shimbun-lump (shimbun) (group-header-alist last-check))
38 (luna-define-internal-accessors 'shimbun-lump))
40 (defun shimbun-lump-lapse-seconds (time)
41 (let ((now (current-time)))
42 (+ (* (- (car now) (car time)) 65536)
43 (- (nth 1 now) (nth 1 time)))))
45 (defun shimbun-lump-check-p (shimbun)
46 (or (null (shimbun-lump-last-check-internal shimbun))
47 (and (shimbun-lump-last-check-internal shimbun)
48 (< (shimbun-lump-lapse-seconds
49 (shimbun-lump-last-check-internal shimbun))
50 shimbun-lump-check-interval))))
52 (defun shimbun-lump-checked (shimbun)
53 (shimbun-lump-set-last-check-internal shimbun (current-time)))
55 (luna-define-generic shimbun-get-group-header-alist (shimbun)
56 "Return an alist of group and header list.")
58 (luna-define-method shimbun-get-headers ((shimbun shimbun-lump))
59 (when (shimbun-lump-check-p shimbun)
60 (shimbun-lump-set-group-header-alist-internal
61 shimbun (shimbun-get-group-header-alist shimbun))
62 (shimbun-lump-checked shimbun))
63 (cdr (assoc (shimbun-current-group-internal shimbun)
64 (shimbun-lump-group-header-alist-internal shimbun))))
66 (luna-define-method shimbun-close :after ((shimbun shimbun-lump))
67 (shimbun-lump-set-group-header-alist-internal shimbun nil)
68 (shimbun-lump-set-last-check-internal shimbun nil))
72 ;;; sb-lump.el ends here