24358
|
1 ;;; nnagent.el --- offline backend for Gnus
|
|
2 ;; Copyright (C) 1997,98 Free Software Foundation, Inc.
|
|
3
|
|
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
|
5 ;; Keywords: news, mail
|
|
6
|
|
7 ;; This file is part of GNU Emacs.
|
|
8
|
|
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
10 ;; it under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 ;; GNU General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 ;; Boston, MA 02111-1307, USA.
|
|
23
|
|
24 ;;; Commentary:
|
|
25
|
|
26 ;;; Code:
|
|
27
|
|
28 (require 'nnheader)
|
|
29 (require 'nnoo)
|
|
30 (eval-when-compile (require 'cl))
|
|
31 (require 'gnus-agent)
|
|
32 (require 'nnml)
|
|
33
|
|
34 (nnoo-declare nnagent
|
|
35 nnml)
|
|
36
|
|
37
|
|
38
|
|
39 (defconst nnagent-version "nnagent 1.0")
|
|
40
|
|
41 (defvoo nnagent-directory nil
|
|
42 "Internal variable."
|
|
43 nnml-directory)
|
|
44
|
|
45 (defvoo nnagent-active-file nil
|
|
46 "Internal variable."
|
|
47 nnml-active-file)
|
|
48
|
|
49 (defvoo nnagent-newsgroups-file nil
|
|
50 "Internal variable."
|
|
51 nnml-newsgroups-file)
|
|
52
|
|
53 (defvoo nnagent-get-new-mail nil
|
|
54 "Internal variable."
|
|
55 nnml-get-new-mail)
|
|
56
|
|
57 ;;; Interface functions.
|
|
58
|
|
59 (nnoo-define-basics nnagent)
|
|
60
|
|
61 (deffoo nnagent-open-server (server &optional defs)
|
|
62 (setq defs
|
|
63 `((nnagent-directory ,(gnus-agent-directory))
|
|
64 (nnagent-active-file ,(gnus-agent-lib-file "active"))
|
|
65 (nnagent-newsgroups-file ,(gnus-agent-lib-file "newsgroups"))
|
|
66 (nnagent-get-new-mail nil)))
|
|
67 (nnoo-change-server 'nnagent server defs)
|
|
68 (let ((dir (gnus-agent-directory))
|
|
69 err)
|
|
70 (cond
|
|
71 ((not (condition-case arg
|
|
72 (file-exists-p dir)
|
|
73 (ftp-error (setq err (format "%s" arg)))))
|
|
74 (nnagent-close-server)
|
|
75 (nnheader-report
|
|
76 'nnagent (or err
|
|
77 (format "No such file or directory: %s" dir))))
|
|
78 ((not (file-directory-p (file-truename dir)))
|
|
79 (nnagent-close-server)
|
|
80 (nnheader-report 'nnagent "Not a directory: %s" dir))
|
|
81 (t
|
|
82 (nnheader-report 'nnagent "Opened server %s using directory %s"
|
|
83 server dir)
|
|
84 t))))
|
|
85
|
|
86 (deffoo nnagent-retrieve-groups (groups &optional server)
|
|
87 (save-excursion
|
|
88 (cond
|
|
89 ((file-exists-p (gnus-agent-lib-file "groups"))
|
|
90 (nnmail-find-file (gnus-agent-lib-file "groups"))
|
|
91 'groups)
|
|
92 ((file-exists-p (gnus-agent-lib-file "active"))
|
|
93 (nnmail-find-file (gnus-agent-lib-file "active"))
|
|
94 'active)
|
|
95 (t nil))))
|
|
96
|
|
97 (defun nnagent-request-type (group article)
|
|
98 (unless (stringp article)
|
|
99 (let ((gnus-plugged t))
|
|
100 (if (not (gnus-check-backend-function
|
|
101 'request-type (car gnus-command-method)))
|
|
102 'unknown
|
|
103 (funcall (gnus-get-function gnus-command-method 'request-type)
|
|
104 (gnus-group-real-name group) article)))))
|
|
105
|
|
106 (deffoo nnagent-request-newgroups (date server)
|
|
107 nil)
|
|
108
|
|
109 (deffoo nnagent-request-update-info (group info &optional server)
|
|
110 nil)
|
|
111
|
|
112 (deffoo nnagent-request-post (&optional server)
|
|
113 (gnus-agent-insert-meta-information 'news gnus-command-method)
|
|
114 (gnus-request-accept-article "nndraft:queue"))
|
|
115
|
|
116 ;; Use nnml functions for just about everything.
|
|
117 (nnoo-import nnagent
|
|
118 (nnml))
|
|
119
|
|
120
|
|
121 ;;; Internal functions.
|
|
122
|
|
123 (provide 'nnagent)
|
|
124
|
|
125 ;;; nnagent.el ends here
|