From c207ba30a9a277407fd69e039c0525f5a25a4ef2 Mon Sep 17 00:00:00 2001 From: ichikawa Date: Mon, 9 Nov 1998 14:44:07 +0000 Subject: [PATCH] lisp/gnus-offline.el and lisp/gnus-ofsetup.el - Beta testing. --- ChangeLog | 8 ++ lisp/gnus-offline.el | 234 +++++++++++--------------------------------------- lisp/gnus-ofsetup.el | 166 +++++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+), 183 deletions(-) create mode 100644 lisp/gnus-ofsetup.el diff --git a/ChangeLog b/ChangeLog index 16085d0..9b6b933 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1998-11-09 Tatsuya Ichikawa + + * lisp/gnus-offline.el: v2.00b1 Separate setting part and + functional part - setting part move to gnus-ofsetup.el (New file). + + * lisp/gnus-ofsetup.el: New file - setting function for + gnus-offline. + 1998-11-09 Katsumi Yamaoka * lisp/pop3-fma.el: Set the value of `nnmail-read-passwd' as a diff --git a/lisp/gnus-offline.el b/lisp/gnus-offline.el index 52a8355..280a870 100644 --- a/lisp/gnus-offline.el +++ b/lisp/gnus-offline.el @@ -1,5 +1,5 @@ ;;; gnus-offline.el --- To process mail & news at offline environment. -;;; $Id: gnus-offline.el,v 1.1.2.5.2.4 1998-10-17 03:27:06 ichikawa Exp $ +;;; $Id: gnus-offline.el,v 1.1.2.5.2.5 1998-11-09 14:44:06 ichikawa Exp $ ;;; Copyright (C) 1998 Tatsuya Ichikawa ;;; Yukihiro Ito @@ -7,7 +7,7 @@ ;;; Yukihiro Ito ;;; Hidekazu Nakamura -;;; Version: 1.54 +;;; Version: 2.00b1 ;;; Keywords: news , mail , offline , gnus ;;; ;;; SPECIAL THANKS @@ -41,39 +41,33 @@ ;;; You must use Semi-gnus 6.X.X. ;;; ;;; How to use. -;;; put following code in you .emacs , after the setting of Gnus. ;;; -;;; (setq gnus-offline-connect-program "/dir/program.exe") -;;; (setq gnus-offline-connect-program-arguments '("-a" "-b")) -;;; (setq gnus-offline-hangup-program "/dir/program") +;;; Add following code at the end in your .emacs +;;; +;;; (load "gnus-ofsetup") +;;; (gnus-setup-for-offline) +;;; (load gnus-offline-setting-file) +;;; +;;; put following code in you .gnus-offline.el. +;;; +;;; (setq gnus-offline-dialup-program-arguments '("-a" "-b")) ;;; (setq gnus-offline-hangup-program-arguments '("-c" "-d")) -;;; (setq gnus-offline-mail-spool-directory "your-send-mail-spool-directory") -;;; (setq gnus-offline-news-spool-directory "your-send-news-spool-directory") -;;; (autoload 'gnus-offline-setup "gnus-offline") -;;; (add-hook 'gnus-load-hook 'gnus-offline-setup) ;;; ;;; If you use gnus-agent as souper , put gnus-agent setup code in you .gnus.el ;;; ;;; If you use nnspool as souper , put following code in your .emacs before ;;; gnus-offline setting. ;;; -;;; (load "miee") -;;; (message-offline-state) -;;; ;;; Then , put hang.exe in exec-path directory. ;;; ;;; In Gnus group buffer , type g to get all news and mail. ;;; Then send mail and news in spool directory. ;;; ;;; Variables. -;;; gnus-offline-connect-program ... Dialup program name. -;;; gnus-offline-connect-program-arguments +;;; gnus-offline-dialup-program-arguments ;;; ... List of dialup program arguments. -;;; gnus-offline-hangup-program ... Program name that used hanup line. ;;; gnus-offline-hangup-program-arguments ;;; ... List of hangup program arguments. -;;; gnus-offline-mail-spool-directory... spool directory sending mail. -;;; gnus-offline-news-spool-directory... spool directory sending news. ;;; gnus-offline-mail-treat-environ ... toggle sending mail online/offline. ;;; gnus-offline-articles-to-fetch ... toggle fetch articles. ;;; both->mail->news->both... @@ -82,14 +76,8 @@ ;;; gnus-offline-after-online-hook ... hook after all online jobs. ;;; gnus-offline-interval-time ... Interval time to do all online jobs. ;;; (minutes) -;;; gnus-offline-MTA-type ... Type of MTA. -;;; 'smtp ... Use smtp.el. -;;; 'sendmail ... Use sendmail.el. -;;; gnus-offline-drafts-queue-type ... Method type queuing message to spool. -;;; 'miee means queue message to spool -;;; using miee.el. -;;; 'agent means queue message to spool -;;; using gnus-agent.el. +;;; gnus-offline-dialup-function ... Function to diualup. +;;; gnus-offline-hangup-function ... Function to hangup. ;;; Code: @@ -115,19 +103,10 @@ :group 'mail :group 'news) -(defconst gnus-offline-version-number "1.54") +(defconst gnus-offline-version-number "2.00b1") (defconst gnus-offline-codename -;; "You may be right" ; 1.40 -;; "Chilstie Lee" ; 1.45 -;; "Uptown Girl" ; 1.46 -;; "Easy money" ; 1.47 -;; "An Innocent man" ; 1.48 -;; "Tell her about it" ; 1.50 -;; "This night" ; 1.51 -;; "Movin'out" ; 1.52 -;; "Longest night" ; 1.53 - "Running on ice" ; 1.54 -;; "This is the time" + "Beta1" +;; "This is the time" ; 2.00 ;; "A matter of trust" ;; "Modern Woman" ;; "Code of silence" @@ -136,22 +115,11 @@ (defconst gnus-offline-version (format "Gnus offline backend utiliy v%s" gnus-offline-version-number)) -(defcustom gnus-offline-connect-program nil - "*Program name to dial-up dialup network. -If nil , use auto-dialup if required to connect the Internet." - :group 'gnus-offline - :type 'string) - -(defcustom gnus-offline-connect-program-arguments nil - "*Program arguments of gnus-offline-connect-program." +(defcustom gnus-offline-dialup-program-arguments nil + "*Program arguments of gnus-offline-dialup-program." :group 'gnus-offline :type '(repeat (string :tag "Argument"))) -(defcustom gnus-offline-hangup-program nil - "*Program name to hang-up dialup network." - :group 'gnus-offline - :type 'string) - (defcustom gnus-offline-hangup-program-arguments nil "*Program arguments of gnus-offline-hangup-program." :group 'gnus-offline @@ -162,16 +130,6 @@ If nil , use auto-dialup if required to connect the Internet." :group 'gnus-offline :type 'boolean) -(defcustom gnus-offline-mail-spool-directory "~/News/mail.out" - "*Spool directory sending mail." - :group 'gnus-offline - :type 'directory) - -(defcustom gnus-offline-news-spool-directory "~/News/news.out" - "*Spool directory sending news." - :group 'gnus-offline - :type 'directory) - (defcustom gnus-offline-load-hook nil "*Hook to be run after the gnus-offline package has been loaded." :group 'gnus-offline @@ -214,22 +172,6 @@ If set to 0 , timer call is disabled." :group 'gnus-offline :type 'integer) -(defcustom gnus-offline-MTA-type 'smtp - "*Type of MTA program. -smtp means use smtp.el. - sendmail means use sendmail.el." - :group 'gnus-offline - :type '(choice (const smtp) - (const sendmail))) - -(defcustom gnus-offline-drafts-queue-type 'agent - "*Type of to queue drafts method. -'miee means drafts are queued and sent by miee.el. -'agent means drafts are queued and sent by gnus-agent.el" - :group 'gnus-offline - :type '(choice (const miee) - (const agent))) - (defcustom gnus-offline-after-empting-spool-hook nil "*Hook to be run before empting spool." :group 'gnus-offline @@ -267,9 +209,6 @@ If value is nil , dialup line is disconnected status.") gnus-offline-codename) "*Header string for gnus-offline.") -(defvar gnus-offline-auto-hangup-indicator "Hup" - "*Indicator whether auto hang up is enabled.") - (defvar gnus-offline-stored-group-level nil "*Mail Group level before changing.") @@ -315,34 +254,19 @@ If value is nil , dialup line is disconnected status.") (make-local-variable 'byte-compile-warnings) (setq byte-compile-warnings nil)))) -(autoload 'message-offline-state "miee" - "Set current status to offline state" t) -;; -;; mode-line control -(if (not (member 'gnus-offline-auto-hangup-indicator mode-line-format)) - (progn - (delete "-%-" mode-line-format) - (setq-default mode-line-format - (append mode-line-format - (list "--" 'gnus-offline-auto-hangup-indicator - "-%-"))))) (put 'gnus-offline-set-unplugged-state 'menu-enable 'gnus-offline-connected) -(add-hook 'gnus-startup-hook 'gnus-offline-setup) ;;; Functions ;; ;; Setting up... ;; (defun gnus-offline-setup () "*Initialize gnus-offline function" - (if (eq system-type 'windows-nt) - (define-process-argument-editing "/hang\\.exe\\'" - (lambda (x) (general-process-argument-editing-function - x nil t t nil t t)))) - ;; Initialize Internal Variable - (gnus-offline-initialize-variables) - - ;; Disable fetch mail when startup. - (gnus-offline-disable-fetch-mail) + + ;; Load setting file - required. + (load gnus-offline-setting-file) + + ;; Menus. + (gnus-offline-define-menu-and-key) ;; To transfer Mail/News function. (cond ((eq gnus-offline-mail-treat-environ 'offline) @@ -350,40 +274,7 @@ If value is nil , dialup line is disconnected status.") (gnus-offline-set-offline-sendmail-function)) ((eq gnus-offline-mail-treat-environ 'online) ;; send mail under offline environ. - (gnus-offline-set-online-sendmail-function))) - - ;; always treat news under offline environ. - (gnus-offline-set-offline-post-news-function) - - ;; Spool directory setting - Miee - (if (eq gnus-offline-drafts-queue-type 'miee) - (progn - (if (not (file-exists-p gnus-offline-mail-spool-directory)) - (make-directory gnus-offline-mail-spool-directory t)) - (setq sendmail-to-spool-directory gnus-offline-mail-spool-directory) - (if (not (file-exists-p gnus-offline-news-spool-directory)) - (make-directory gnus-offline-news-spool-directory t)) - (setq news-spool-request-post-directory gnus-offline-news-spool-directory))) - - ;; When startup ... state is offline. - (setq gnus-nntp-service nil - gnus-nntp-server nil) - - ;; Setup needed Hooks - (gnus-offline-setup-needed-hooks)) -;; -;; -(defun gnus-offline-initialize-variables () - "*Initialize gnus-offline internal variable." - (if (featurep 'nnmail) - (setq gnus-offline-mail-fetch-method 'nnmail)) - (if (featurep 'gnus-agent) - (setq gnus-offline-news-fetch-method 'nnagent)) - (if (featurep 'nnspool) - (setq gnus-offline-news-fetch-method 'nnspool)) - (if (eq gnus-offline-drafts-queue-type 'miee) - (load "miee")) - (gnus-offline-define-menu-and-key)) + (gnus-offline-set-online-sendmail-function)))) ;; ;; (defun gnus-offline-set-offline-sendmail-function () @@ -407,17 +298,6 @@ If value is nil , dialup line is disconnected status.") "*Initialize sendnews-function when plugged status." (setq message-send-news-function 'message-send-news-with-gnus)) ;; -(defun gnus-offline-setup-needed-hooks () - "*Initialize needed hooks for gnus-offline." - (add-hook 'gnus-group-mode-hook 'gnus-offline-processed-by-timer) - (add-hook 'gnus-after-getting-new-news-hook 'gnus-offline-after-get-new-news) - (add-hook 'gnus-after-getting-news-hook 'gnus-offline-after-get-new-news) - (if (eq gnus-offline-news-fetch-method 'nnspool) - (add-hook 'after-getting-news-hook 'gnus-offline-nnspool-hangup-line)) - (add-hook 'mime-edit-translate-hook 'gnus-offline-message-add-header) - (if (featurep 'pop3-fma) - (add-hook 'mime-edit-translate-hook 'pop3-fma-message-add-header))) -;; ;; Get new news jobs. (gnus-agent and nnspool) ;; (defun gnus-offline-gnus-get-new-news (&optional arg) @@ -434,12 +314,12 @@ If value is nil , dialup line is disconnected status.") ;; (defun gnus-offline-connect-server () "*Dialup function." - ;; Dialup if gnus-offline-connect-program is specified - (if (stringp gnus-offline-connect-program) + ;; Dialup if gnus-offline-dialup-program is specified + (if (stringp gnus-offline-dialup-program) (progn (message "Dialing ...") - (apply 'call-process gnus-offline-connect-program nil nil nil - gnus-offline-connect-program-arguments) + (apply 'call-process gnus-offline-dialup-program nil nil nil + gnus-offline-dialup-program-arguments) (sleep-for 1) (message "Dialing ... done.")))) @@ -452,11 +332,6 @@ If value is nil , dialup line is disconnected status.") (if (eq gnus-offline-articles-to-fetch 'mail) (gnus-offline-set-mail-group-level gnus-offline-mail-group-level)) - ;; Re initialize internal variable...if failed. - (if (or (not gnus-offline-mail-fetch-method) - (not gnus-offline-news-fetch-method)) - (gnus-offline-initialize-variables)) - ;; Set to online environ. (setq gnus-offline-connected t) @@ -562,23 +437,20 @@ If value is nil , dialup line is disconnected status.") ;; (defun gnus-offline-disable-fetch-mail () "*Set do not fetch mail." - (if (eq gnus-offline-mail-fetch-method 'nnmail) - (setq nnmail-spool-file nil))) + (setq nnmail-spool-file nil)) ;; ;; Enable fetch mail ;; (defun gnus-offline-enable-fetch-mail () "*Set to fetch mail." - (if (eq gnus-offline-mail-fetch-method 'nnmail) - (progn - (setq gnus-offline-mail-fetch-method 'nnmail) - (setq nnmail-movemail-program 'pop3-fma-movemail) - (setq nnmail-spool-file (append - pop3-fma-local-spool-file-alist - (mapcar - (lambda (spool) - (car spool)) - pop3-fma-spool-file-alist)))))) + (setq gnus-offline-mail-fetch-method 'nnmail) + (setq nnmail-movemail-program 'pop3-fma-movemail) + (setq nnmail-spool-file (append + pop3-fma-local-spool-file-alist + (mapcar + (lambda (spool) + (car spool)) + pop3-fma-spool-file-alist)))) ;; ;; Enable fetch news ;; @@ -699,10 +571,8 @@ If value is nil , dialup line is disconnected status.") (if gnus-offline-auto-hangup (progn (setq gnus-offline-auto-hangup nil - gnus-offline-auto-hangup-indicator "Con" str "disabled.")) (setq gnus-offline-auto-hangup t - gnus-offline-auto-hangup-indicator "Hup" str "enabled.")) (message (format "%s %s" string str))) ;; @@ -853,14 +723,13 @@ If value is nil , dialup line is disconnected status.") (cons "Gnus Offline Utility" (make-sparse-keymap "Gnus Offline Utiliry"))) - (if (featurep 'pop3-fma) - (global-set-key - [menu-bar - miee - gnus-offline - gnus-offline-toggle-movemail-program] - '("Toggle movemail program" . - gnus-offline-toggle-movemail-program))) + (global-set-key + [menu-bar + miee + gnus-offline + gnus-offline-toggle-movemail-program] + '("Toggle movemail program" . + gnus-offline-toggle-movemail-program)) (global-set-key [menu-bar @@ -931,12 +800,11 @@ If value is nil , dialup line is disconnected status.") (cons "Offline" (make-sparse-keymap "Offline")) 'help) ;; Actually this adds before "Help". - (if (featurep 'pop3-fma) - (global-set-key - [menu-bar - offline - gnus-offline-toggle-movemail-program] - '("Toggle movemail program" . gnus-offline-toggle-movemail-program))) + (global-set-key + [menu-bar + offline + gnus-offline-toggle-movemail-program] + '("Toggle movemail program" . gnus-offline-toggle-movemail-program)) (global-set-key [menu-bar diff --git a/lisp/gnus-ofsetup.el b/lisp/gnus-ofsetup.el new file mode 100644 index 0000000..0a813b4 --- /dev/null +++ b/lisp/gnus-ofsetup.el @@ -0,0 +1,166 @@ +;;; gnus-ofsetup.el --- Setup advisor for Offline reading for Mail/News. +;;; $Id: gnus-ofsetup.el,v 1.1.2.1 1998-11-09 14:44:07 ichikawa Exp $ + +;;; Code: + +(defvar gnus-offline-setting-file "~/.gnus-offline.el") +(defvar gnus-offline-use-miee nil) + +;;; To silence byte compiler +(and + (fboundp 'eval-when-compile) + (eval-when-compile + (save-excursion + (beginning-of-defun) + (eval-region (point-min) (point))) + (let (case-fold-search) + (mapcar + (function + (lambda (symbol) + (unless (boundp symbol) + (make-local-variable symbol) + (eval (list 'setq symbol nil))))) + '(:group + :prefix :type + sendmail-to-spool-directory + news-spool-request-post-directory + nnspool-version + nnagent-version + msspool-news-server + msspool-news-service + gnspool-get-news + mail-spool-send + news-spool-post + gnus-agent-handle-level + )) + (make-local-variable 'byte-compile-warnings) + (setq byte-compile-warnings nil)))) + +(defun gnus-setup-for-offline () + "*Set up Gnus for offline environment." + (interactive) + + (if (not (file-exists-p gnus-offline-setting-file)) + (progn + (let ((news-method + (completing-read + "Select method for offline News reading: " + '(("gnus-agent" 1) ("nnspool" 2)) + nil t nil)) + (mail-method 'nnmail) + (use-miee + (y-or-n-p "Use MIEE post/send message ")) + (program + (read-from-minibuffer "Dialup/Hangup program: ")) + (mta-type + (completing-read + "Select MTA type for sending mail: " + '(("smtp" 1) ("sendmail" 2)) + nil t nil)) + ) + (if (equal news-method "gnus-agent") + (setq gnus-offline-news-fetch-method 'nnagent) + (setq gnus-offline-news-fetch-method 'nnspool)) + (setq gnus-offline-mail-fetch-method mail-method) + (setq gnus-offline-use-miee use-miee) + (setq gnus-offline-hangup-program program) + (setq gnus-offline-dialup-program program) + (if use-miee + (progn + ;; Setting for MIEE. + (let ((news-spool + (read-from-minibuffer "News spool directory for sending: ")) + (mail-spool + (read-from-minibuffer "Mail spool directory for sending: "))) + (setq gnus-offline-mail-spool-directory mail-spool) + (setq gnus-offline-news-spool-directory news-spool) + (setq gnus-offline-drafts-queue-type 'miee))) + ;; Setting for gnus-agent. + (setq gnus-offline-drafts-queue-type 'agent) + (let ((agent-directory + (read-from-minibuffer "Agent directory: " "~/News/agent"))) + (setq gnus-agent-directory agent-directory))) + (if (equal mta-type "smtp") + (setq gnus-offline-MTA-type 'smtp) + (setq gnus-offline-MTA-type 'sendmail) + ) + + ;; Set offline news posting function and post directory using MIEE. + (if gnus-offline-use-miee + (progn + ;; Load MIEE. + (load "miee") + ;; Set news post function for MIEE. + (setq message-send-news-function 'gnspool-request-post) + + ;; Spool directory setting - MIEE. + (if (not (file-exists-p gnus-offline-mail-spool-directory)) + (make-directory gnus-offline-mail-spool-directory t)) + (setq sendmail-to-spool-directory gnus-offline-mail-spool-directory) + (if (not (file-exists-p gnus-offline-news-spool-directory)) + (make-directory gnus-offline-news-spool-directory t)) + (setq news-spool-request-post-directory gnus-offline-news-spool-directory))) + ) + + ;; Write to setting file. + (setq tmp-buffer (get-buffer-create "* Setting")) + (set-buffer "* Setting") + (erase-buffer) + (insert ";;\n"); + (insert ";; This file is created by gnus-ofsetup.el\n") + (insert ";; Creation date : ") + (insert (current-time-string)) + (insert "\n") + (insert ";;\n") + (insert "(setq gnus-offline-news-fetch-method '") + (insert (prin1-to-string gnus-offline-news-fetch-method)) + (insert ")\n") + (insert "(setq gnus-offline-mail-fetch-method '") + (insert (prin1-to-string gnus-offline-mail-fetch-method)) + (insert ")\n") + (insert "(setq gnus-offline-use-miee ") + (insert (prin1-to-string gnus-offline-use-miee)) + (insert ")\n") + (insert "(setq gnus-offline-dialup-program ") + (insert (prin1-to-string gnus-offline-dialup-program)) + (insert ")\n") + (insert "(setq gnus-offline-hangup-program ") + (insert (prin1-to-string gnus-offline-hangup-program)) + (insert ")\n") + (if gnus-offline-use-miee + (progn + (insert "(setq gnus-offline-mail-spool-directory ") + (insert (prin1-to-string gnus-offline-mail-spool-directory)) + (insert ")\n") + (insert "(setq gnus-offline-news-spool-directory ") + (insert (prin1-to-string gnus-offline-news-spool-directory)) + (insert ")\n") + (insert "(load \"miee\")\n") + (insert "(message-offline-state)\n")) + (insert "(setq gnus-agent-directory ") + (insert (prin1-to-string gnus-agent-directory)) + (insert ")\n")) + (insert "(setq gnus-offline-drafts-queue-type '") + (insert (prin1-to-string gnus-offline-drafts-queue-type)) + (insert ")\n") + (insert "(setq gnus-offline-MTA-type '") + (insert (prin1-to-string gnus-offline-MTA-type)) + (insert ")\n") + (insert "(setq gnus-nntp-service nil)\n") + (insert "(setq gnus-nntp-server nil)\n") + (insert "(setq nnmail-spool-file nil)\n") + (insert "(add-hook 'gnus-group-mode-hook 'gnus-offline-processed-by-timer)\n") + (insert "(add-hook 'gnus-after-getting-new-news-hook 'gnus-offline-after-get-new-news)\n") + (insert "(add-hook 'gnus-after-getting-news-hook 'gnus-offline-after-get-new-news)\n") + (if (eq gnus-offline-news-fetch-method 'nnspool) + (insert "(add-hook 'after-getting-news-hook 'gnus-offline-nnspool-hangup-line)\n")) + (insert "(add-hook 'message-send-hook 'gnus-offline-message-add-header)\n") + (insert "(require 'pop3-fma)\n") + (insert "(add-hook 'message-send-hook 'pop3-fma-message-add-header)\n") + (insert "(autoload 'gnus-offline-setup \"gnus-offline\")\n") + (insert "(add-hook 'gnus-load-hook 'gnus-offline-setup)\n") + (write-region (point-min) (point-max) gnus-offline-setting-file) + (kill-buffer "* Setting")) + ) + (load gnus-offline-setting-file) + ) -- 1.7.10.4