;;; nndb.el --- nndb access for Gnus;; Copyright (C) 1996 Free Software Foundation, Inc.;; Author: Kai Grossjohann <grossjohann@ls6.informatik.uni-dortmund.de>;; Keywords: news;; This file is part of GNU Emacs.;; GNU Emacs is free software; you can redistribute it and/or modify;; it under the terms of the GNU General Public License as published by;; the Free Software Foundation; either version 2, or (at your option);; any later version.;; GNU Emacs is distributed in the hope that it will be useful,;; but WITHOUT ANY WARRANTY; without even the implied warranty of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the;; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License;; along with GNU Emacs; see the file COPYING. If not, write to the;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,;; Boston, MA 02111-1307, USA.;;; Commentary:;; I have shamelessly snarfed the code of nntp.el from sgnus.;; Kai;;-;; Register nndb with known select methods.(setqgnus-valid-select-methods(cons'("nndb"mailaddressrespoolprompt-address)gnus-valid-select-methods));;; Code:(require'nnheader)(require'nntp)(eval-when-compile(require'cl))(eval-and-compile(unless(fboundp'open-network-stream)(require'tcp)))(eval-when-compile(require'cl))(eval-and-compile(autoload'news-setup"rnewspost")(autoload'news-reply-mode"rnewspost")(autoload'cancel-timer"timer")(autoload'telnet"telnet"nilt)(autoload'telnet-send-input"telnet"nilt)(autoload'timezone-parse-date"timezone"));; Declare nndb as derived from nntp(nnoo-declarenndbnntp);; Variables specific to nndb;;- currently not used but just in case...(defvoonndb-deliver-program"nndel""*The program used to put a message in an NNDB group.");; Variables copied from nntp(defvoonndb-server-opened-hook'(nntp-send-authinfo-from-file)"Like nntp-server-opened-hook."nntp-server-opened-hook);(defvoo nndb-rlogin-parameters '("telnet" "${NNDBSERVER:=localhost}" "9000"); "*Parameters to nndb-open-login. Like nntp-rlogin-parameters."; nntp-rlogin-parameters);(defvoo nndb-rlogin-user-name nil; "*User name for rlogin connect method."; nntp-rlogin-user-name)(defvoonndb-address"localhost""*The name of the NNDB server."nntp-address)(defvoonndb-port-number9000"*Port number to connect to."nntp-port-number);(defvoo nndb-current-group ""; "Like nntp-current-group."; nntp-current-group)(defvoonndb-status-stringnil""nntp-status-string)(defconstnndb-version"nndb 0.3""Version numbers of this version of NNDB.");;; Interface functions.(nnoo-define-basicsnndb);; Import other stuff from nntp as is.(nnoo-importnndb(nntp));;- maybe this should be mail??;;-(defun nndb-request-type (group &optional article);;- 'news);;------------------------------------------------------------------;;- only new stuff below; nndb-request-update-info does not exist and is not needed; nndb-request-update-mark does not exist and is not needed; nndb-request-scan does not exist; get new mail from somewhere -- maybe this is not needed?; --> todo(deffoonndb-request-create-group(group&optionalserver)"Creates a group if it doesn't exist yet."(nntp-send-command"^[23].*\n""MKGROUP"group)); todo -- use some other time than the creation time of the article; best is time since article has been marked as expirable(deffoonndb-request-expire-articles(articles&optionalgroupserverforce)"Expires ARTICLES from GROUP on SERVER.If FORCE, delete regardless of exiration date, otherwise use normalexpiry mechanism."(let(msgart)(nntp-possibly-change-servergroupserver);;-(whilearticles(setqart(poparticles))(nntp-send-command"^\\([23]\\|^423\\).*\n""DATE"art)(setqmsg(nndb-status-message));; CCC we shouldn't be using the variable nndb-status-string?(if(string-match"^423"(nnheader-get-report'nndb))()(or(string-match"\\([0-9]+\\) \\([0-9]+\\)$"msg)(error"Not a valid response for DATE command: %s"msg))(if(nnmail-expired-article-pgroup(list(string-to-int(substringmsg(match-beginning1)(match-end1)))(string-to-int(substringmsg(match-beginning2)(match-end2))))force)(nnheader-message5"Deleting article %s in %s..."artgroup)(nntp-send-command"^[23].*\n""DELETE"art))))))(deffoonndb-request-move-article(articlegroupserveraccept-form&optionallast)"Move ARTICLE (a number) from GROUP on SERVER.Evals ACCEPT-FORM in current buffer, where the article is.Optional LAST is ignored."(let((artbuf(get-buffer-create" *nndb move*"))result)(and(nndb-request-articlearticlegroupserverartbuf)(save-excursion(set-bufferartbuf)(setqresult(evalaccept-form))(kill-buffer(current-buffer))result)(nndb-request-expire-articles(listarticle)groupservert))result))(deffoonndb-request-accept-article(groupserver&optionallast)"The article in the current buffer is put into GROUP."(nntp-possibly-change-servergroupserver);;-(let(artstatmsg)(when(nntp-send-command"^[23].*\r?\n""ACCEPT"group)(nnheader-insert"")(nntp-encode-text)(nntp-send-region-to-server(point-min)(point-max));; 1.2a NNTP's post command is buggy. "^M" (\r) is not;; appended to end of the status message.(nntp-wait-for-response"^[23].*\n")(setqstatmsg(nntp-status-message))(or(string-match"^\\([0-9]+\\)"statmsg)(error"nndb: %s"statmsg))(setqart(substringstatmsg(match-beginning1)(match-end1)))(message"nndb: accepted %s"art)(listart))))(deffoonndb-request-replace-article(articlegroupbuffer)"ARTICLE is the number of the article in GROUP to be replaced with the contents of the BUFFER."(set-bufferbuffer)(let(artstatmsg)(when(nntp-send-command"^[23].*\r?\n""REPLACE"(int-to-stringarticle))(nnheader-insert"")(nntp-encode-text)(nntp-send-region-to-server(point-min)(point-max));; 1.2a NNTP's post command is buggy. "^M" (\r) is not;; appended to end of the status message.(nntp-wait-for-response"^[23].*\n"); (setq statmsg (nntp-status-message)); (or (string-match "^\\([0-9]+\\)" statmsg); (error "nndb: %s" statmsg)); (setq art (substring statmsg; (match-beginning 1); (match-end 1))); (message "nndb: replaced %s" art)(list(int-to-stringarticle))))); nndb-request-delete-group does not exist; todo -- maybe later; nndb-request-rename-group does not exist; todo -- maybe later(provide'nndb)