*** empty log message ***
[gnus] / lisp / nndir.el
1 ;;; nndir.el --- single directory newsgroup access for Gnus
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;;      Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (require 'nnheader)
29 (require 'nnmh)
30 (require 'nnml)
31
32 \f
33
34 (defconst nndir-version "nndir 0.0")
35
36 (defvar nndir-current-directory nil
37   "Current news group directory.")
38
39 (defvar nndir-status-string "")
40
41 (defvar nndir-nov-is-evil nil
42   "*Non-nil means that nndir will never retrieve NOV headers.")
43
44 \f
45
46 ;;; Interface functions.
47
48
49 (defun nndir-retrieve-headers (sequence &optional newsgroup server)
50   (nndir-execute-nnml-command
51    '(nnml-retrieve-headers sequence group server) server))
52
53 (defun nndir-open-server (host &optional service)
54   "Open nndir backend."
55   (setq nndir-status-string "")
56   (nnheader-init-server-buffer))
57
58 (defun nndir-close-server (&optional server)
59   "Close news server."
60   t)
61
62 (defun nndir-server-opened (&optional server)
63   "Return server process status, T or NIL.
64 If the stream is opened, return T, otherwise return NIL."
65   (and nntp-server-buffer
66        (get-buffer nntp-server-buffer)))
67
68 (defun nndir-status-message ()
69   "Return server status response as string."
70   nndir-status-string)
71
72 (defun nndir-request-article (id &optional newsgroup server buffer)
73   (nndir-execute-nnmh-command
74    '(nnmh-request-article id group server buffer) server))
75
76 (defun nndir-request-group (group &optional server dont-check)
77   "Select news GROUP."
78   (nndir-execute-nnmh-command
79    '(nnmh-request-group group "" dont-check) server))
80
81 (defun nndir-request-list (&optional server dir)
82   "Get list of active articles in all newsgroups."
83   (nndir-execute-nnmh-command
84    '(nnmh-request-list nil dir) server))
85
86 (defun nndir-request-newgroups (date &optional server)
87   (nndir-execute-nnmh-command
88    '(nnmh-request-newgroups date server) server))
89
90 (defun nndir-request-post (&optional server)
91   "Post a new news in current buffer."
92   (mail-send-and-exit nil))
93
94 (fset 'nndir-request-post-buffer 'nnmail-request-post-buffer)
95
96 (defun nndir-request-expire-articles (articles newsgroup &optional server force)
97   "Expire all articles in the ARTICLES list in group GROUP."
98   (setq nndir-status-string "nndir: expire not possible")
99   nil)
100
101 (defun nndir-close-group (group &optional server)
102   t)
103
104 (defun nndir-request-move-article (article group server accept-form)
105   (setq nndir-status-string "nndir: move not possible")
106   nil)
107
108 (defun nndir-request-accept-article (group)
109   (setq nndir-status-string "nndir: accept not possible")
110   nil)
111
112 \f
113 ;;; Low-Level Interface
114
115 (defun nndir-execute-nnmh-command (command server)
116   (let ((dir (expand-file-name server)))
117     (and (string-match "/$" dir)
118          (setq dir (substring dir 0 (match-beginning 0))))
119     (string-match "/[^/]+$" dir)
120     (let ((group (substring dir (1+ (match-beginning 0))))
121           (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
122           (nnmh-get-new-mail nil))
123       (eval command))))
124
125 (defun nndir-execute-nnml-command (command server)
126   (let ((dir (expand-file-name server)))
127     (and (string-match "/$" dir)
128          (setq dir (substring dir 0 (match-beginning 0))))
129     (string-match "/[^/]+$" dir)
130     (let ((group (substring dir (1+ (match-beginning 0))))
131           (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
132           (nnml-nov-is-evil nndir-nov-is-evil)
133           (nnml-get-new-mail nil))
134       (eval command))))
135
136 (provide 'nndir)
137
138 ;;; nndir.el ends here