(message-unique-id): Comment change.
[gnus] / lisp / nnagent.el
1 ;;; nnagent.el --- offline backend for Gnus
2
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
4 ;;        Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news, mail
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs 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)
14 ;; any later version.
15
16 ;; GNU Emacs 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.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (require 'nnheader)
31 (require 'nnoo)
32 (eval-when-compile (require 'cl))
33 (require 'gnus-agent)
34 (require 'nnml)
35
36 (nnoo-declare nnagent
37   nnml)
38
39 \f
40
41 (defconst nnagent-version "nnagent 1.0")
42
43 (defvoo nnagent-directory nil
44   "Internal variable."
45   nnml-directory)
46
47 (defvoo nnagent-active-file nil
48   "Internal variable."
49   nnml-active-file)
50
51 (defvoo nnagent-newsgroups-file nil
52   "Internal variable."
53   nnml-newsgroups-file)
54
55 (defvoo nnagent-get-new-mail nil
56   "Internal variable."
57   nnml-get-new-mail)
58
59 ;;; Interface functions.
60
61 (nnoo-define-basics nnagent)
62
63 (defun nnagent-server (server)
64   (and server (format "%s+%s" (car gnus-command-method) server)))
65
66 (deffoo nnagent-open-server (server &optional defs)
67   (setq defs
68         `((nnagent-directory ,(gnus-agent-directory))
69           (nnagent-active-file ,(gnus-agent-lib-file "active"))
70           (nnagent-newsgroups-file ,(gnus-agent-lib-file "newsgroups"))
71           (nnagent-get-new-mail nil)))
72   (nnoo-change-server 'nnagent
73                       (nnagent-server server)
74                       defs)
75   (let ((dir (gnus-agent-directory))
76         err)
77     (cond
78      ((not (condition-case arg
79                (file-exists-p dir)
80              (ftp-error (setq err (format "%s" arg)))))
81       (nnagent-close-server)
82       (nnheader-report
83        'nnagent (or err
84                     (format "No such file or directory: %s" dir))))
85      ((not (file-directory-p (file-truename dir)))
86       (nnagent-close-server)
87       (nnheader-report 'nnagent "Not a directory: %s" dir))
88      (t
89       (nnheader-report 'nnagent "Opened server %s using directory %s"
90                        server dir)
91       t))))
92
93 (deffoo nnagent-retrieve-groups (groups &optional server)