-\f
-;;; Low-Level Interface
-
-(defun nndir-execute-nnmh-command (command server)
- (let ((dir (expand-file-name server)))
- (and (string-match "/$" dir)
- (setq dir (substring dir 0 (match-beginning 0))))
- (string-match "/[^/]+$" dir)
- (let ((group (substring dir (1+ (match-beginning 0))))
- (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
- (nnmh-get-new-mail nil))
- (eval command))))
-
-(defun nndir-execute-nnml-command (command server)
- (let ((dir (expand-file-name server)))
- (and (string-match "/$" dir)
- (setq dir (substring dir 0 (match-beginning 0))))
- (string-match "/[^/]+$" dir)
- (let ((group (substring dir (1+ (match-beginning 0))))
- (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
- (nnml-nov-is-evil nndir-nov-is-evil)
- (nnml-get-new-mail nil))
- (eval command))))
+(nnoo-define-basics nndir)
+
+(deffoo nndir-open-server (server &optional defs)
+ (setq nndir-directory
+ (or (cadr (assq 'nndir-directory defs))
+ server))
+ (unless (assq 'nndir-directory defs)
+ (push `(nndir-directory ,server) defs))
+ ;(when (equal server "")
+ ; (setq server (cadr (assq 'nndir-directory defs))))
+ (push `(nndir-current-group
+ ,(file-name-nondirectory (directory-file-name nndir-directory)))
+ defs)
+ (push `(nndir-top-directory
+ ,(file-name-directory (directory-file-name nndir-directory)))
+ defs)
+ (nnoo-change-server 'nndir server defs)
+ (let (err)
+ (cond
+ ((not (condition-case arg
+ (file-exists-p nndir-directory)
+ (ftp-error (setq err (format "%s" arg)))))
+ (nndir-close-server)
+ (nnheader-report
+ 'nndir (or err "No such file or directory: %s" nndir-directory)))
+ ((not (file-directory-p (file-truename nndir-directory)))
+ (nndir-close-server)
+ (nnheader-report 'nndir "Not a directory: %s" nndir-directory))
+ (t
+ (nnheader-report 'nndir "Opened server %s using directory %s"
+ server nndir-directory)
+ t))))
+
+(nnoo-map-functions nndir
+ (nnml-retrieve-headers 0 nndir-current-group 0 0)
+ (nnmh-request-article 0 nndir-current-group 0 0)
+ (nnmh-request-group nndir-current-group 0 0)
+ (nnml-close-group nndir-current-group 0)
+ (nnmh-request-list (nnoo-current-server 'nndir) nndir-directory)
+ (nnmh-request-newsgroups (nnoo-current-server 'nndir) nndir-directory))