;;; 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
;;; Yukihiro Ito <ito@rs.civil.tohoku.ac.jp>
;;; Hidekazu Nakamura <u90121@uis-inf.co.jp>
-;;; Version: 1.54
+;;; Version: 2.00b1
;;; Keywords: news , mail , offline , gnus
;;;
;;; SPECIAL THANKS
;;; 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...
;;; 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:
: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"
(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
: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
: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
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.")
(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)
(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 ()
"*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)
;;
(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."))))
(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)
;;
(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
;;
(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)))
;;
(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
(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
--- /dev/null
+;;; 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)
+ )